2025-06-22 00:21:09 +03:00

58 lines
4.6 KiB
JavaScript

import { i as is_promise, a as noop } from "../../../../chunks/utils.js";
import { c as create_ssr_component, g as getContext, b as each, a as add_attribute, e as escape, v as validate_component } from "../../../../chunks/ssr.js";
import { T as Trash2Icon } from "../../../../chunks/Trash2Icon.js";
import "../../../../chunks/walletStore.js";
import "@stellar/stellar-sdk";
import { T as TruncatedKey } from "../../../../chunks/TruncatedKey.js";
import "../../../../chunks/horizonQueries.js";
import "../../../../chunks/transactions.js";
const network = "testnet";
const baseUrl = `https://api.stellar.expert/explorer/${network}`;
async function fetchAssets() {
let res = await fetch(
`${baseUrl}/asset?${new URLSearchParams({
// these are all the defaults, but you could customize them if needed
search: "",
sort: "rating",
order: "desc",
limit: "10",
cursor: "0"
})}`
);
let json = await res.json();
let records = json._embedded.records;
return records;
}
const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => {
let balances;
let { data } = $$props;
getContext("simple-modal");
if ($$props.data === void 0 && $$bindings.data && data !== void 0) $$bindings.data(data);
balances = data.balances ?? [];
return ` <h1 data-svelte-h="svelte-ofbnzl">Assets</h1> <p data-svelte-h="svelte-vs451h">The <code>/dashboard/assets</code> page will allow the user to manage the Stellar assets their account
carries trustlines to. On this page, they can select from several pre-suggested or highly ranked
assets, or they could specify their own asset to trust using an asset code and issuer public key.
They can also remove trustlines that already exist on their account.</p> <h2 data-svelte-h="svelte-1ncy5wr">Add Trusted Assets</h2> <p data-svelte-h="svelte-15igzoy">Add a trustline on your account, allowing you to hold the specified asset.</p> <select class="select-bordered select my-2 w-full"><option disabled selected value="" data-svelte-h="svelte-ag327d">Select Asset</option><option disabled value="These two assets are issued by the SDF testanchor, and are great for using in tests" data-svelte-h="svelte-dnweoa">These two assets are issued by the SDF testanchor, and are great for using in tests</option><option value="SRT:GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B" data-svelte-h="svelte-cqfv65">testanchor SRT:GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B</option><option value="USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5" data-svelte-h="svelte-19heakl">testanchor USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5</option>${function(__value) {
if (is_promise(__value)) {
__value.then(null, noop);
return ``;
}
return function(assets) {
return ` <option disabled value="The following assets have been ranked by Stellar.Expert to be high-quality" data-svelte-h="svelte-2ob6qq">The following assets have been ranked by Stellar.Expert to be high-quality</option> ${each(assets, ({ asset }) => {
return `${asset !== "XLM" ? (() => {
let assetString = `${asset.split("-")[0]}:${asset.split("-")[1]}`;
return ` <option${add_attribute("value", assetString, 0)}>${escape(assetString)}</option>`;
})() : ``}`;
})} `;
}(__value);
}(fetchAssets())}<option disabled value="Need something else?" data-svelte-h="svelte-cp573k">Need something else?</option><option value="custom" data-svelte-h="svelte-o4qf5i">Custom asset...</option></select> ${``} <button class="btn-primary btn-block btn my-2" data-svelte-h="svelte-g54wjn">Add Asset</button> <h2 data-svelte-h="svelte-15igkao">Existing Balances</h2> <p data-svelte-h="svelte-nmu1b7">View or remove asset trustlines on your Stellar account.</p> <div class="flex items-center"><table class="table table-auto"><thead data-svelte-h="svelte-1r2gly7"><tr><th>Asset</th> <th>Balance</th> <th class="w-xs">Issuer</th> <th>Actions</th></tr></thead> <tbody>${each(balances, (balance) => {
return `<tr><th>${"asset_code" in balance ? `${escape(balance.asset_code)}` : `XLM`}</th> <td>${escape(balance.balance)}</td> <td>${"asset_issuer" in balance ? `${validate_component(TruncatedKey, "TruncatedKey").$$render($$result, { keyText: balance.asset_issuer }, {}, {})}` : ``}</td> <td>${"asset_code" in balance ? (() => {
`${balance.asset_code}:${balance.asset_issuer}`;
return ` <button class="btn-error btn-square btn-sm btn">${validate_component(Trash2Icon, "Trash2Icon").$$render($$result, { size: "16" }, {}, {})}</button>`;
})() : ``}</td> </tr>`;
})}</tbody></table></div>`;
});
export {
Page as default
};