Skip to content

Commit 4e0a97f

Browse files
authored
Modify swap info program (#93)
1 parent d1c4f30 commit 4e0a97f

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

guest-examples/swap-info/src/main.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,16 @@ mod swap_info {
6767
}
6868

6969
#[program::entrypoint]
70-
fn entrypoint_list_pools() -> alloc::vec::Vec<(AssetId, AssetId)> {
71-
list_pools()
72-
}
73-
74-
#[program::entrypoint]
75-
fn entrypoint_asset_info(asset: AssetId) -> Option<AssetInfo> {
76-
asset_info(asset)
70+
fn entrypoint_list_pools() -> alloc::vec::Vec<(AssetInfo, AssetInfo)> {
71+
let pools = list_pools();
72+
let mut result = alloc::vec::Vec::new();
73+
for pool in pools {
74+
let asset1_info = asset_info(pool.0.clone());
75+
let asset2_info = asset_info(pool.1.clone());
76+
if let (Some(a1), Some(a2)) = (asset1_info, asset2_info) {
77+
result.push((a1, a2));
78+
}
79+
}
80+
result
7781
}
7882
}

pvq-test-runner/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub enum ExtensionFungiblesFunctions {
1818
#[extensions_impl]
1919
pub mod extensions {
2020
use parity_scale_codec::Decode;
21+
2122
#[extensions_impl::impl_struct]
2223
pub struct ExtensionsImpl;
2324

0 commit comments

Comments
 (0)