diff --git a/bin/cli.mjs b/bin/cli.mjs index 23b87be..37d5390 100755 --- a/bin/cli.mjs +++ b/bin/cli.mjs @@ -181,8 +181,6 @@ const installPackage = async () => { await exec( `npm run install --scarb-version=${tool_versions.scarb} --legacy-peer-deps` ); - - // await exec("npm run install-tools"); } else if (packageType !== "contract_only") { await exec("npm run install --legacy-peer-deps"); } @@ -194,6 +192,8 @@ const installPackage = async () => { if (packageType == "kakarot") { console.log(` npm run start-kakarot`); + } else if (packageType == "contract_only") { + console.log(` npm run devnet`); } else { console.log(` npm run start`); } diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e9eaadc..8a02c45 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -825,8 +825,6 @@ }, "node_modules/@parcel/watcher-wasm/node_modules/napi-wasm": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/napi-wasm/-/napi-wasm-1.1.0.tgz", - "integrity": "sha512-lHwIAJbmLSjF9VDRm9GoVOy9AGp3aIvkjv+Kvz9h16QR3uSVYH78PNQUnT2U4X53mhlnV2M7wrhibQ3GHicDmg==", "inBundle": true, "license": "MIT" }, diff --git a/frontend/src/app/burner/page.tsx b/frontend/src/app/burner/page.tsx index 4c762e4..47f0386 100644 --- a/frontend/src/app/burner/page.tsx +++ b/frontend/src/app/burner/page.tsx @@ -58,10 +58,14 @@ export default function Page() { TransactionHash.transaction_hash, ); + const address: string = result.events?.at(0).from_address; + const formattedAddress = + "0x" + address.replace(/^0x/, "").padStart(64, "0"); + return { privateKey, publicKey, - address: result.events?.at(0).from_address, + address: formattedAddress, }; }; diff --git a/frontend/src/app/common/abis/erc20-metadata.ts b/frontend/src/app/common/abis/erc20-metadata.ts new file mode 100644 index 0000000..1cc1f40 --- /dev/null +++ b/frontend/src/app/common/abis/erc20-metadata.ts @@ -0,0 +1,37 @@ +import { Abi } from "starknet"; + +export const erc20MetadataAbi: Abi = [ + { + name: "symbol", + type: "function", + inputs: [], + outputs: [ + { + type: "core::felt252", + }, + ], + state_mutability: "view", + }, + { + name: "name", + type: "function", + inputs: [], + outputs: [ + { + type: "core::felt252", + }, + ], + state_mutability: "view", + }, + { + name: "decimals", + type: "function", + inputs: [], + outputs: [ + { + type: "core::integer::u8", + }, + ], + state_mutability: "view", + }, +]; diff --git a/frontend/src/app/components/lib/AddToken.tsx b/frontend/src/app/components/lib/AddToken.tsx index a67e5c0..4c85906 100644 --- a/frontend/src/app/components/lib/AddToken.tsx +++ b/frontend/src/app/components/lib/AddToken.tsx @@ -1,8 +1,11 @@ "use client"; -import { useState } from "react"; -import { useConnect } from "@starknet-react/core"; +import { useEffect, useState } from "react"; +import { useConnect, useContractRead } from "@starknet-react/core"; +import { shortString } from "starknet"; import Close from "public/svg/Close"; import GenericModal from "../internal/util/GenericModal"; +import { erc20MetadataAbi } from "@/app/common/abis/erc20-metadata"; + const AddTokenModal = () => { const { connector } = useConnect(); const [tokenAddress, setTokenAddress] = useState(""); @@ -10,6 +13,39 @@ const AddTokenModal = () => { const [decimals, setDecimals] = useState(""); const [name, setName] = useState(""); + const { data: tokenName } = useContractRead({ + abi: erc20MetadataAbi, + functionName: "name", + address: tokenAddress, + args: [], + }); + + const { data: tokenSymbol } = useContractRead({ + abi: erc20MetadataAbi, + functionName: "symbol", + address: tokenAddress, + args: [], + }); + + const { data: tokenDecimals } = useContractRead({ + abi: erc20MetadataAbi, + functionName: "decimals", + address: tokenAddress, + args: [], + }); + + useEffect(() => { + tokenName + ? setName(shortString.decodeShortString(tokenName.toString())) + : setName(""); + + tokenSymbol + ? setSymbol(shortString.decodeShortString(tokenSymbol.toString())) + : setSymbol(""); + + tokenDecimals ? setDecimals(tokenDecimals.toString()) : setDecimals(""); + }, [tokenName, tokenSymbol, tokenDecimals]); + function handleAddToken() { const fetchAddToken = async () => { try {