Skip to content

Commit

Permalink
add rpc url props in token and nft card component
Browse files Browse the repository at this point in the history
  • Loading branch information
mymiracle0118 committed Jul 13, 2024
1 parent 3bf75d7 commit 53083fe
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import type { AssetAccount } from "$lib/types.js";
// issuer: "GCAR7OJULRZBOMMUPJ33YMI3O6GPBMKHWVWQAD2BHSH6NZ25QYMI44UP"
// }

// export const nftInfo: AssetAccount = {
// code: "CYBERMAN007",
// issuer: "GABSMRCVPJJQZ3PDYKR4B3UCU26JBMJFSWEQVQAHPDEFHDMSJI3IQ7IT"
// }

export const nftInfo: AssetAccount = {
code: "CYBERMAN007",
issuer: "GABSMRCVPJJQZ3PDYKR4B3UCU26JBMJFSWEQVQAHPDEFHDMSJI3IQ7IT"
code: "MSNFT",
issuer: "GATRMB7RI7EJDWNWZUJ3E75MTMU5UYWLUJS6IRVR3BFLL3YF5WGAGBUA"
}

export const tokenInfo: AssetAccount = {
Expand Down
4 changes: 1 addition & 3 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ export const sizes: Record<SizeType | "none", string> = {
md: "max-w-xl",
lg: "max-w-2xl",
xl: "max-w-screen-xl",
};

export const baseURL: string = "https://horizon.stellar.org/";
};
4 changes: 3 additions & 1 deletion src/lib/nftPoster/nftPoster.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
export let assetAccount: AssetAccount;
export let imgClass: string | undefined = undefined;
export let baseURL: string;
export let padding: SizeType | 'none' = 'lg';
interface $$Props extends ComponentProps<Frame> {
assetAccount: AssetAccount;
imgClass?:string;
padding?: SizeType | 'none';
baseURL: string;
}
const paddings: Record<SizeType | 'none', string> = {
Expand Down Expand Up @@ -47,7 +49,7 @@
let assetMetadata: AssetMetaData;
async function getNFTData(assetAccount: AssetAccount) {
const data = await getMetadata(assetAccount);
const data = await getMetadata(baseURL, assetAccount);
if(data?.result) {
assetInfo = data.data?.asset_raw as AssetRaw;
assetMetadata = data.data?.metadata as AssetMetaData;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/tokenPoster/tokenPoster.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
export let assetAccount: AssetAccount;
export let imgClass: string | undefined = undefined;
export let baseURL: string;
export let padding: SizeType | 'none' = 'lg';
interface $$Props extends ComponentProps<Frame> {
assetAccount: AssetAccount;
imgClass?:string;
padding?: SizeType | 'none';
baseURL: string;
}
const paddings: Record<SizeType | 'none', string> = {
Expand Down Expand Up @@ -47,7 +49,7 @@
let assetMetadata: AssetMetaData;
async function getAssetData(assetAccount: AssetAccount) {
const data = await getMetadata(assetAccount);
const data = await getMetadata(baseURL, assetAccount);
if(data?.result) {
assetInfo = data.data?.asset_raw as AssetRaw;
assetMetadata = data.data?.metadata as AssetMetaData;
Expand Down
3 changes: 1 addition & 2 deletions src/lib/utility.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { AssetAccount, AssetRaw, AssetStatistics, AssetFlag, AssetMetaData, links, SizeType } from '$lib/types.js';
import { baseURL } from '$lib/constants.js';

function convertDataToAssetRaw(_data: any): AssetRaw {
return {
Expand Down Expand Up @@ -81,7 +80,7 @@ async function fetchToml(request: string, code: string) {
}
}

export async function getMetadata(assetAccount: AssetAccount) {
export async function getMetadata(baseURL: string, assetAccount: AssetAccount) {
if (assetAccount == undefined) return;
let request = baseURL + "assets?asset_code=" + assetAccount.code + "&asset_issuer=" + assetAccount.issuer;
try {
Expand Down
12 changes: 8 additions & 4 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import CanvasModal from '$lib/CanvasModal/Modal.svelte';
import { nftInfo, tokenInfo } from '../constants.js';
import Jumbotron from '$lib/JumboTron/index.svelte';
import TokenPoster from '$lib/tokenPoster/tokenPoster.svelte';
import TokenPoster from '$lib/tokenPoster/tokenPoster.svelte';
let recordMouseMoveTrack = true;
let intervalData = 5;
let testnetBaseURL = "https://horizon-testnet.stellar.org/";
let mainnetBaseURL = "https://horizon.stellar.org/";
let isMouseEntered = false;
let showModal = false;
Expand All @@ -27,7 +29,7 @@
img="/images/wallet.webp"
imgClass="m-lg rounded-lg"
isMouseTrackRecord={recordMouseMoveTrack}
dataURL="http://localhost/api"
dataURL="http://localhost/api"
intervalData={intervalData}
>
<h5 class="mb-2 text-xl tracking-tight text-gray-900 ">Meta stellar card</h5>
Expand Down Expand Up @@ -76,7 +78,8 @@
<div class="w-1/2">
<NftPoster
isMouseTrackRecord={recordMouseMoveTrack}
dataURL="http://localhost/api"
dataURL="http://localhost/api"
baseURL = {testnetBaseURL}
intervalData={intervalData}
hoverTransform
imgHoverTransform
Expand All @@ -92,7 +95,8 @@
<div class="w-1/2">
<TokenPoster
isMouseTrackRecord={recordMouseMoveTrack}
dataURL="http://localhost/api"
baseURL = {mainnetBaseURL}
dataURL="http://localhost/api"
intervalData={intervalData}
hoverTransform
imgHoverTransform
Expand Down

0 comments on commit 53083fe

Please sign in to comment.