Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: small ui updates #27

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/components/AccountSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
starknetReactVersionAtom,
starknetkitVersionAtom,
} from "@/state/versionState"
import { Box, Flex, Heading } from "@chakra-ui/react"
import { Box, Flex, Heading, useToast } from "@chakra-ui/react"
import { useAtomValue } from "jotai"
import { FC } from "react"
import { constants, num } from "starknet"
Expand All @@ -26,6 +26,7 @@ const AccountSection: FC<AccountSectionProps> = ({ address, chainId }) => {
const lastTxError = useAtomValue(lastTxErrorAtom)
const starknetkitVersion = useAtomValue(starknetkitVersionAtom)
const starknetReactVersion = useAtomValue(starknetReactVersionAtom)
const toast = useToast()

const hexChainId =
typeof chainId === "bigint" ? num.toHex(chainId ?? 0) : null
Expand All @@ -37,7 +38,22 @@ const AccountSection: FC<AccountSectionProps> = ({ address, chainId }) => {
{starknetReactVersion && <Heading>{starknetReactVersion}</Heading>}
</Flex>
<Section>
<Box>Account: {address}</Box>
<Box
cursor={address ? "pointer" : "default"}
onClick={() => {
if (address) {
navigator.clipboard.writeText(address || "")
toast({
title: "Address copied",
duration: 1000,
containerStyle: { minWidth: "50px" },
status: "success",
})
}
}}
>
Account: {address}
</Box>
<Box>
Chain:{" "}
{!hexChainId
Expand Down
9 changes: 8 additions & 1 deletion src/components/Actions/SessionKeysExecuteOutside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useAtomValue } from "jotai"
import { useState } from "react"
import { Abi, Calldata, Contract, RawArgs, shortString, stark } from "starknet"
import Erc20Abi from "../../abi/ERC20.json"
import { Box, Button, Flex, Heading, Input } from "@chakra-ui/react"
import { Box, Button, Flex, Heading, Input, useToast } from "@chakra-ui/react"

type OutsideExecution = {
contractAddress: string
Expand All @@ -33,6 +33,7 @@ const SessionKeysExecuteOutside = ({}) => {
const sessionRequest = useAtomValue(sessionRequestAtom)
const connectorData = useAtomValue(connectorDataAtom)
const transactionStatus = useAtomValue(lastTxStatusAtom)
const toast = useToast()

const [amount, setAmount] = useState("")
const [outsideExecution, setOutsideExecution] = useState<
Expand Down Expand Up @@ -117,6 +118,12 @@ const SessionKeysExecuteOutside = ({}) => {

const copyData = () => {
navigator.clipboard.writeText(JSON.stringify(outsideExecution))
toast({
title: "Outside execution payload copied",
duration: 1000,
containerStyle: { minWidth: "50px" },
status: "success",
})
}

return (
Expand Down
9 changes: 8 additions & 1 deletion src/components/Actions/SessionKeysTypedDataOutside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SessionDappService,
buildSessionAccount,
} from "@argent/x-sessions"
import { Button, Flex, Heading, Input } from "@chakra-ui/react"
import { Button, Flex, Heading, Input, useToast } from "@chakra-ui/react"
import { useAtomValue } from "jotai"
import { useState } from "react"
import { Abi, Contract, stark } from "starknet"
Expand All @@ -28,6 +28,7 @@ const SessionKeysTypedDataOutside = () => {
const sessionRequest = useAtomValue(sessionRequestAtom)
const connectorData = useAtomValue(connectorDataAtom)
const transactionStatus = useAtomValue(lastTxStatusAtom)
const toast = useToast()

const [amount, setAmount] = useState("")
const [outsideExecution, setOutsideExecution] = useState<
Expand Down Expand Up @@ -110,6 +111,12 @@ const SessionKeysTypedDataOutside = () => {

const copyData = () => {
navigator.clipboard.writeText(JSON.stringify(outsideExecution))
toast({
title: "Outside execution typed data copied",
duration: 1000,
containerStyle: { minWidth: "50px" },
status: "success",
})
}

return (
Expand Down
6 changes: 0 additions & 6 deletions src/services/universalTransactionExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ export const universalTransactionExecuteJSONRpcMethod = async ({
throw Error("wallet not connected")
}

console.log({
contract_address,
entry_point,
calldata,
})

return wallet.request({
type: "wallet_addInvokeTransaction",
params: {
Expand Down