Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ jobs:
# Generate guest program list dynamically
generate-guest-matrix:
runs-on: ubuntu-latest
# Run on main branches, release branches, or when explicitly requested
# Run on main branches, release branches, PRs to master, or when explicitly requested
if: |
github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/v') ||
github.base_ref == 'master' ||
contains(github.event.pull_request.labels.*.name, 'full-build')
outputs:
guest-matrix: ${{ steps.generate-matrix.outputs.guest-matrix }}
Expand Down Expand Up @@ -189,7 +190,7 @@ jobs:
collect-guests:
runs-on: ubuntu-latest
needs: [generate-guest-matrix, build-guest]
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'full-build')
if: github.event_name == 'push' || github.base_ref == 'master' || contains(github.event.pull_request.labels.*.name, 'full-build')
steps:
- name: Download all guest artifacts
uses: actions/download-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions guest-examples/sum-balance-percent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ mod sum_balance_percent {
type AssetId = u32;
type AccountId = [u8; 32];
type Balance = u64;
#[program::extension_fn(extension_id = 4071833530116166512u64, fn_index = 1)]
#[program::extension_fn(extension_id = 1248491991627109725u64, fn_index = 6)]
fn balance(asset: AssetId, who: AccountId) -> Balance {}
#[program::extension_fn(extension_id = 4071833530116166512u64, fn_index = 0)]
#[program::extension_fn(extension_id = 1248491991627109725u64, fn_index = 5)]
fn total_supply(asset: AssetId) -> Balance {}

#[program::entrypoint]
Expand Down
2 changes: 1 addition & 1 deletion guest-examples/sum-balance/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod sum_balance {
}
}

#[program::extension_fn(extension_id = 4071833530116166512u64, fn_index = 1)]
#[program::extension_fn(extension_id = 1248491991627109725u64, fn_index = 6)]
fn balance(asset: AssetId, who: AccountId) -> Balance {}

#[program::entrypoint]
Expand Down
27 changes: 21 additions & 6 deletions poc/runtime/src/pvq.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[allow(unused_imports)]
use frame::deps::scale_info::prelude::{format, string::String};

use pvq_extension::metadata::Metadata;
use pvq_extension::{extensions_impl, ExtensionsExecutor, InvokeSource};

#[extensions_impl]
pub mod extensions {
use frame::deps::scale_info::prelude::vec::Vec;
use frame::token::fungibles;

#[extensions_impl::impl_struct]
pub struct ExtensionImpl;

Expand All @@ -20,14 +20,29 @@ pub mod extensions {

#[extensions_impl::extension]
impl pvq_extension_fungibles::extension::ExtensionFungibles for ExtensionImpl {
type AccountId = [u8; 32];
type AccountId = crate::interface::AccountId;
type Balance = crate::interface::Balance;
type AssetId = crate::interface::AssetId;
fn name(asset: Self::AssetId) -> Vec<u8> {
<crate::Assets as fungibles::metadata::Inspect<crate::interface::AccountId>>::name(asset)
}
fn symbol(asset: Self::AssetId) -> Vec<u8> {
<crate::Assets as fungibles::metadata::Inspect<crate::interface::AccountId>>::symbol(asset)
}
fn decimals(asset: Self::AssetId) -> u8 {
<crate::Assets as fungibles::metadata::Inspect<crate::interface::AccountId>>::decimals(asset)
}
fn balance(asset: Self::AssetId, who: Self::AccountId) -> Self::Balance {
crate::Assets::balance(asset, crate::interface::AccountId::from(who))
<crate::Assets as fungibles::Inspect<crate::interface::AccountId>>::balance(asset, &who)
}
fn total_supply(asset: Self::AssetId) -> Self::Balance {
crate::Assets::total_supply(asset)
<crate::Assets as fungibles::Inspect<crate::interface::AccountId>>::total_issuance(asset)
}
fn minimum_balance(asset: Self::AssetId) -> Self::Balance {
<crate::Assets as fungibles::Inspect<crate::interface::AccountId>>::minimum_balance(asset)
}
fn asset_exists(asset: Self::AssetId) -> bool {
<crate::Assets as fungibles::Inspect<crate::interface::AccountId>>::asset_exists(asset)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions pvq-extension-fungibles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ use pvq_extension::extension_decl;

#[extension_decl]
pub mod extension {
use scale_info::prelude::vec::Vec;
#[extension_decl::extension]
pub trait ExtensionFungibles {
type AssetId;
type Balance;
type AccountId;
fn asset_exists(asset: Self::AssetId) -> bool;
fn name(asset: Self::AssetId) -> Vec<u8>;
fn symbol(asset: Self::AssetId) -> Vec<u8>;
fn decimals(asset: Self::AssetId) -> u8;
fn minimum_balance(asset: Self::AssetId) -> Self::Balance;
fn total_supply(asset: Self::AssetId) -> Self::Balance;
fn balance(asset: Self::AssetId, who: Self::AccountId) -> Self::Balance;
}
Expand Down
18 changes: 18 additions & 0 deletions pvq-test-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,24 @@ pub mod extensions {
type AssetId = u32;
type AccountId = [u8; 32];
type Balance = u64;
fn name(_asset: Self::AssetId) -> Vec<u8> {
b"Test".to_vec()
}
fn symbol(_asset: Self::AssetId) -> Vec<u8> {
b"TEST".to_vec()
}
fn decimals(_asset: Self::AssetId) -> u8 {
18
}
fn total_supply(_asset: Self::AssetId) -> Self::Balance {
100
}
fn minimum_balance(_asset: Self::AssetId) -> Self::Balance {
100
}
fn asset_exists(_asset: Self::AssetId) -> bool {
true
}
fn balance(_asset: Self::AssetId, _who: Self::AccountId) -> Self::Balance {
100
}
Expand Down Expand Up @@ -133,6 +148,9 @@ impl TestRunner {

pub fn expected_result(program_path: &str, chain: &str, entrypoint_idx: u8) -> Vec<u8> {
// TODO: add more entrypoints
if program_path.contains("sum-balance") && chain == "poc" && entrypoint_idx == 0 {
return 1_000_000_000u64.encode();
}
if program_path.contains("swap-info") && chain == "ah" && entrypoint_idx == 2 {
return (10_235_709_412_325u128, 12_117_819_770_919u128).encode();
}
Expand Down
Loading