-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added ft tools,cleaned a styled code
- Loading branch information
Showing
15 changed files
with
1,833 additions
and
1,519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
import { Accordion, Flex, Text } from "@near-pagoda/ui"; | ||
import Image from "next/image"; | ||
import { Accordion, Flex, Text } from '@near-pagoda/ui'; | ||
import Image from 'next/image'; | ||
|
||
const ListToken = ({ tokens }) => { | ||
|
||
import type { FT } from '@/pages/tools'; | ||
|
||
const ListToken = ({ tokens }: { tokens: FT[] }) => { | ||
return ( | ||
<Accordion.Root type="multiple"> | ||
<Accordion.Item value="one"> | ||
<Accordion.Item value="one"> | ||
<Accordion.Trigger>Tokens you minted</Accordion.Trigger> | ||
<Accordion.Content> | ||
{tokens.map((token) => { | ||
return ( | ||
<Flex justify="space-between" align="center"> | ||
<Text>{token.name}</Text> | ||
<Text>{token.symbol}</Text> | ||
<Text>{token.total_supply/ 10 ** token.decimals}</Text> | ||
<Image src={token.icon} alt={token.name} width={50} height={50}/> | ||
</Flex> | ||
); | ||
})} | ||
{tokens.map((token) => { | ||
return ( | ||
<Flex justify="space-between" align="center" key={`ft-${token.symbol}`}> | ||
<Text>{token.name}</Text> | ||
<Text>{token.symbol}</Text> | ||
<Text>{BigInt(token.total_supply) / BigInt(Math.pow(10, Number(token.decimals)))}</Text> | ||
<Image src={token.icon} alt={token.name} width={50} height={50} /> | ||
</Flex> | ||
); | ||
})} | ||
</Accordion.Content> | ||
</Accordion.Item> | ||
</Accordion.Item> | ||
</Accordion.Root> | ||
); | ||
}; | ||
|
||
export default ListToken; | ||
export default ListToken; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,15 @@ | ||
// https://dev.near.org/contractwizard.near/widget/ContractWizardUI | ||
// curl https://api.fastnear.com/v1/account/here.tg/ft | ||
// https://github.com/fastnear/fastnear-api-server-rs?tab=readme-ov-file#api-v1 | ||
// near call tkn.near create_token '{"args":{"owner_id": "maguila.near","total_supply": "1000000000","metadata":{"spec": "ft-1.0.0","name": "Test Token","symbol": "TTTEST","icon": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","decimals": 18}},"account_id": "maguila.near"}' --gas 300000000000000 --depositYocto 2234830000000000000000000 --accountId maguila.near --networkId mainnet | ||
// https://docs.near.org/build/primitives/ft | ||
import type { FT } from '@/pages/tools'; | ||
|
||
import { Card, Flex, SvgIcon, Text, Title, Tooltip } from '@near-pagoda/ui'; | ||
import { CheckFat, ListNumbers, PlusCircle } from '@phosphor-icons/react'; | ||
import { useState } from 'react'; | ||
import CreateTokenForm from './CreateTokenForm'; | ||
import ListToken from './ListToken'; | ||
|
||
|
||
const formattedBalance = (balance: string, decimals = 24) => { | ||
const numericBalance = Number(balance); | ||
if (isNaN(numericBalance) || isNaN(decimals)) { | ||
return '0'; | ||
} | ||
const result = numericBalance / Math.pow(10, decimals); | ||
return result % 1 === 0 ? result.toString() : result.toFixed(5).replace(/\.?0+$/, ''); | ||
}; | ||
|
||
const FungibleToken = ({ tokens }) => { | ||
|
||
const FungibleToken = ({ tokens }: { tokens: FT[] }) => { | ||
return ( | ||
<> | ||
<CreateTokenForm /> | ||
<hr /> | ||
<ListToken tokens={tokens}/> | ||
<ListToken tokens={tokens} /> | ||
</> | ||
); | ||
}; | ||
export default FungibleToken; | ||
|
||
|
||
/* | ||
<hr /> | ||
<Title> </Title> | ||
{tokens.map((token, index) => ( | ||
<Card key={index} style={{ marginBottom: '8px' }}> | ||
<Flex align="center" justify="space-between"> | ||
<Flex align="center" style={{ flex: "1" }} > | ||
<Text>{token.icon && <img width={25} height={25} alt={token.symbol} src={token.icon} />}</Text> | ||
</Flex> | ||
<Text style={{ flex: "1" }} size="text-l">{formattedBalance(token.balance, token.decimals)}</Text> | ||
<Flex justify="end" align='center' style={{ flex: "1" }}> | ||
<Text>{token.symbol}</Text> | ||
{/* {token.verified && ( *\/} | ||
<Tooltip content="It is verified"> | ||
<SvgIcon icon={<CheckFat /> /*<SealCheck />*\/} size="m" color="violet8" /> | ||
</Tooltip> | ||
{/* )} \/} | ||
</Flex> | ||
</Flex> | ||
</Card> | ||
))} | ||
*/ |
Oops, something went wrong.