Skip to content

Commit

Permalink
good show
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-3 committed Oct 18, 2024
1 parent d705e24 commit 14b5c26
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 142 deletions.
10 changes: 5 additions & 5 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@



<script type="module" nonce="t0LfUgPd4UXIy4DCAb95cQ==">
import init, * as bindings from '/trader-leptos-6572d88cbc04ebda.js';
const wasm = await init('/trader-leptos-6572d88cbc04ebda_bg.wasm');
<script type="module" nonce="WNRs4e88vHHfrGRGXMEQng==">
import init, * as bindings from '/trader-leptos-e4d32d3da689c697.js';
const wasm = await init('/trader-leptos-e4d32d3da689c697_bg.wasm');


window.wasmBindings = bindings;
Expand Down Expand Up @@ -44,8 +44,8 @@
});
</script>

<link rel="modulepreload" href="/trader-leptos-6572d88cbc04ebda.js" crossorigin=anonymous integrity="sha384-vlHYhpp/ywnGR+q7fi6RnLvNPrghGYorK4rlfGeoZn+EZbCMxAJBJTXTTayBu9J2">
<link rel="preload" href="/trader-leptos-6572d88cbc04ebda_bg.wasm" crossorigin=anonymous integrity="sha384-hJ8wrz93xIpfV2Q9qz8m6yBKeQPoS41EwILpAD/uIv+vZixdrg+KTvlsQt9lJFpT" as="fetch" type="application/wasm"></head>
<link rel="modulepreload" href="/trader-leptos-e4d32d3da689c697.js" crossorigin=anonymous integrity="sha384-HLbjcfWK9Wvmxaf62M2vGZsBxz7tOChXvQHUsy6GMI8iDdiPiBeytykjyVtKCPq7">
<link rel="preload" href="/trader-leptos-e4d32d3da689c697_bg.wasm" crossorigin=anonymous integrity="sha384-71TInIjzyb+6qssSF8UL9HeFVFbcq1SkOpCiyHK/5BHfRkkp+rSP2/5j2AgHJVdk" as="fetch" type="application/wasm"></head>

<style>
.spinner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ function __wbg_get_imports() {
const ret = typeof(val) === 'object' && val !== null;
return ret;
};
imports.wbg.__wbindgen_is_null = function(arg0) {
const ret = getObject(arg0) === null;
return ret;
};
imports.wbg.__wbindgen_cb_drop = function(arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
Expand All @@ -545,10 +549,6 @@ function __wbg_get_imports() {
const ret = false;
return ret;
};
imports.wbg.__wbindgen_is_null = function(arg0) {
const ret = getObject(arg0) === null;
return ret;
};
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand Down Expand Up @@ -1371,44 +1371,44 @@ function __wbg_get_imports() {
const ret = wasm.memory;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper17509 = function(arg0, arg1, arg2) {
const ret = makeClosure(arg0, arg1, 1200, __wbg_adapter_48);
imports.wbg.__wbindgen_closure_wrapper17385 = function(arg0, arg1, arg2) {
const ret = makeClosure(arg0, arg1, 1542, __wbg_adapter_48);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper17511 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 1204, __wbg_adapter_51);
imports.wbg.__wbindgen_closure_wrapper17387 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 1546, __wbg_adapter_51);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper21817 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2488, __wbg_adapter_54);
imports.wbg.__wbindgen_closure_wrapper21586 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2458, __wbg_adapter_54);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper21822 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2488, __wbg_adapter_57);
imports.wbg.__wbindgen_closure_wrapper21591 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2458, __wbg_adapter_57);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper21824 = function(arg0, arg1, arg2) {
const ret = makeClosure(arg0, arg1, 2488, __wbg_adapter_60);
imports.wbg.__wbindgen_closure_wrapper21593 = function(arg0, arg1, arg2) {
const ret = makeClosure(arg0, arg1, 2458, __wbg_adapter_60);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper22207 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2668, __wbg_adapter_63);
imports.wbg.__wbindgen_closure_wrapper21976 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2638, __wbg_adapter_63);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper22498 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2783, __wbg_adapter_66);
imports.wbg.__wbindgen_closure_wrapper22267 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2753, __wbg_adapter_66);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper24060 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 3485, __wbg_adapter_69);
imports.wbg.__wbindgen_closure_wrapper23829 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 3455, __wbg_adapter_69);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper24062 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 3485, __wbg_adapter_69);
imports.wbg.__wbindgen_closure_wrapper23831 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 3455, __wbg_adapter_69);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper25754 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 3541, __wbg_adapter_74);
imports.wbg.__wbindgen_closure_wrapper25523 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 3511, __wbg_adapter_74);
return addHeapObject(ret);
};

Expand Down
Binary file not shown.
115 changes: 2 additions & 113 deletions src/routes/trade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,115 +398,6 @@ pub fn Trade() -> impl IntoView {
let (token_x, set_token_x) = query_signal_with_options::<String>("from", nav_options.clone());
let (token_y, set_token_y) = query_signal_with_options::<String>("to", nav_options.clone());

// let token_map = Arc::new(token_map.0);
let (token_map, _) = signal(token_map.0);

// let token_x_balance = Resource::new(
// move || (token_x.get(), keplr.enabled.get()),
// move |(contract_address, enabled)| {
// let map = token_map.get();
//
// SendWrapper::new({
// async move {
// if !enabled {
// return "Balance: 👀".to_string();
// }
// let Some(contract_address) = contract_address else {
// return "Select a token".to_string();
// };
// let Some(token) = map.get(&contract_address) else {
// return "Token not in map".to_string();
// };
// match Keplr::get_secret_20_viewing_key(CHAIN_ID, &contract_address).await {
// Ok(vk) => {
// debug!("Found viewing key for {}!\n{vk}", token.metadata.symbol);
// let compute = ComputeQuerier::new(
// wasm_client.get_untracked(),
// Keplr::get_enigma_utils(CHAIN_ID).into(),
// );
// let code_hash = compute
// .code_hash_by_contract_address(&token.contract_address)
// .await
// .expect("failed to query the code hash");
// debug!(
// "contract_address: {}\n\
// code_hash: {}",
// &token.contract_address, code_hash
// );
// let address =
// keplr.key.get_untracked().unwrap().unwrap().bech32_address;
// let query = secret_toolkit_snip20::QueryMsg::Balance {
// address: address,
// key: vk,
// };
// debug!("query: {query:?}");
// let result = compute
// .query_secret_contract(&token.contract_address, code_hash, query)
// .await
// .unwrap();
// debug!("{result}");
//
// let result: BalanceResponse = serde_json::from_str(&result).unwrap();
// format!("Balance: {}", result.balance.amount.to_string())
// }
// Err(err) => {
// debug!("{}", err.to_string());
// "viewing key missing".to_string()
// }
// }
// }
// })
// },
// );

let token_y_balance = AsyncDerived::new_unsync({
// let map = token_map.clone();
move || {
// let map = map.clone();
let url = endpoint.get();
async move {
if let Some(token) = token_y.get() {
let map = token_map.get();
let token = map.get(&token).unwrap();
match Keplr::get_secret_20_viewing_key(CHAIN_ID, &token.contract_address).await
{
Ok(vk) => {
debug!("Found viewing key for {}!", token.metadata.symbol);
let compute = ComputeQuerier::new(
WebWasmClient::new(url),
Keplr::get_enigma_utils(CHAIN_ID).into(),
);
let code_hash = compute
.code_hash_by_contract_address(&token.contract_address)
.await
.expect("failed to query the code hash");
let address = keplr.key.get().unwrap().unwrap().bech32_address;
let query = secret_toolkit_snip20::QueryMsg::Balance {
address: address,
key: vk,
};
let result = compute
.query_secret_contract(&token.contract_address, code_hash, query)
.await
.unwrap();
let result: secret_toolkit_snip20::Balance =
serde_json::from_str(&result).unwrap();
let factor = 10u128.pow(token.metadata.decimals as u32);
let result = result.amount.u128() as f64 / factor as f64;
format!("Balance: {}", result.to_string())
}
Err(err) => {
debug!("{}", err.to_string());
"viewing key missing".to_string()
}
}
} else {
"Select a token".to_string()
}
}
}
});

let (amount_x, set_amount_x) = signal(String::default());
let (amount_y, set_amount_y) = signal(String::default());
let (swap_for_y, set_swap_for_y) = signal(true);
Expand Down Expand Up @@ -679,9 +570,7 @@ pub fn Trade() -> impl IntoView {
<div class="space-y-2">
<div class="flex justify-between">
<div>"To"</div>
<div class="py-0 px-2 hover:bg-violet-500/20 text-ellipsis">
"Balance: 👀"
</div>
<SnipBalance token_address=token_y.into() />
</div>
<div class="flex justify-between space-x-2">
<input
Expand Down Expand Up @@ -728,7 +617,7 @@ pub fn Trade() -> impl IntoView {
</select>
</div>
</div>
<button class="p-1 block">"Estimate Swap"</button>
<button disabled class="p-1 block">"Estimate Swap"</button>
<button
class="p-1 block"
disabled=move || !keplr.enabled.get()
Expand Down

0 comments on commit 14b5c26

Please sign in to comment.