Skip to content

Commit

Permalink
Merge pull request #156 from EjembiEmmanuel/main
Browse files Browse the repository at this point in the history
feat: fixes and improvements
  • Loading branch information
Darlington02 authored Nov 24, 2024
2 parents 618bbdd + dcfdd14 commit 1b14a25
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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`);
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion frontend/src/app/burner/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
};

Expand Down
37 changes: 37 additions & 0 deletions frontend/src/app/common/abis/erc20-metadata.ts
Original file line number Diff line number Diff line change
@@ -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",
},
];
40 changes: 38 additions & 2 deletions frontend/src/app/components/lib/AddToken.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,51 @@
"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("");
const [symbol, setSymbol] = useState("");
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 {
Expand Down

0 comments on commit 1b14a25

Please sign in to comment.