-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
115b552
commit 1efa323
Showing
29 changed files
with
872 additions
and
126 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
[workspace] | ||
members = ["query-balance", "query-balance-fungibles", "transparent-call"] | ||
members = [ | ||
"sum-balance", | ||
"sum-balance-percent", | ||
"total-supply", | ||
"transparent-call", | ||
] | ||
resolver = "2" | ||
|
||
|
||
[workspace.dependencies] | ||
polkavm-derive = { path = "../../vendor/polkavm/crates/polkavm-derive" } | ||
xcq-api = { path = "../../xcq-api", default-features = false } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
poc/guests/query-balance/Cargo.toml → poc/guests/sum-balance-percent/Cargo.toml
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,8 +1,9 @@ | ||
[package] | ||
name = "poc-guest-query-balance" | ||
name = "poc-guest-sum-balance-percent" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
polkavm-derive = { workspace = true } | ||
xcq-api = { workspace = 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 @@ | ||
#![no_std] | ||
#![no_main] | ||
#[global_allocator] | ||
static GLOBAL: polkavm_derive::LeakingAllocator = polkavm_derive::LeakingAllocator; | ||
use alloc::vec::Vec; | ||
#[xcq_api::program] | ||
mod sum_balance { | ||
#[xcq::call_def] | ||
fn balance(asset: u32, who: [u8; 32]) -> u64 {} | ||
#[xcq::call_def] | ||
fn total_supply(asset: u32) -> u64 {} | ||
|
||
#[xcq::entrypoint] | ||
fn sum_balance(balances: Vec<BalanceCall>, total_supply: TotalSupplyCall) -> u64 { | ||
let mut sum_balance = 0; | ||
for call in balances { | ||
sum_balance += call.call(); | ||
} | ||
sum_balance * 100 / total_supply.call() | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...guests/query-balance-fungibles/Cargo.toml → poc/guests/sum-balance/Cargo.toml
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,8 +1,9 @@ | ||
[package] | ||
name = "poc-guest-query-balance-fungibles" | ||
name = "poc-guest-sum-balance" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
polkavm-derive = { workspace = true } | ||
xcq-api = { workspace = 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,19 @@ | ||
#![no_std] | ||
#![no_main] | ||
#[global_allocator] | ||
static GLOBAL: polkavm_derive::LeakingAllocator = polkavm_derive::LeakingAllocator; | ||
use alloc::vec::Vec; | ||
#[xcq_api::program] | ||
mod sum_balance { | ||
#[xcq::call_def] | ||
fn balance(asset: u32, who: [u8; 32]) -> u64 {} | ||
|
||
#[xcq::entrypoint] | ||
fn sum_balance(calls: Vec<BalanceCall>) -> u64 { | ||
let mut sum = 0; | ||
for call in calls { | ||
sum += call.call(); | ||
} | ||
sum | ||
} | ||
} |
Oops, something went wrong.