Skip to content

Commit

Permalink
types / write refactor & finalize hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrosario committed Nov 20, 2023
1 parent b12fade commit d05dd70
Show file tree
Hide file tree
Showing 25 changed files with 878 additions and 296 deletions.
36 changes: 23 additions & 13 deletions example/components/DepositETH.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { Button } from './Button'
import { InputGroup } from './InputGroup'
import { Modal } from './Modal'

const portal = '0xe93c8cD0D409341205A592f8c4Ac1A5fe5585cfA'

type DepositETHModalProps = {
isOpen: boolean
onClose: () => void
Expand All @@ -22,13 +20,14 @@ function DepositETHModal({ isOpen, onClose }: DepositETHModalProps) {
args: {
to: to as Address,
gasLimit: 100000,
amount: parseEther(amount),
},
portal,
chainId: 5,
value: parseEther(amount),
l2ChainId: 84531,
query: { enabled: false },
})
const { data, status: writeStatus, writeDepositETHAsync } = useWriteDepositETH()
const { data: l1TxHash, l2TxHash, status: writeStatus, writeDepositETHAsync } = useWriteDepositETH({
l2ChainId: 84531,
})

const handleClick = async () => {
if (action === 'simulate') {
Expand All @@ -39,10 +38,8 @@ function DepositETHModal({ isOpen, onClose }: DepositETHModalProps) {
args: {
to: to as Address,
gasLimit: 100000,
amount: parseEther(amount),
},
portal,
chainId: 5,
value: parseEther(amount),
})
} catch (e) {
console.error(e)
Expand Down Expand Up @@ -76,16 +73,29 @@ function DepositETHModal({ isOpen, onClose }: DepositETHModalProps) {
<span className='text-white'>Status:</span>
<span className='text-white'>{writeStatus}</span>
</div>
{data && (
{l1TxHash && (
<div className='flex flex-row justify-center space-x-8 items-center w-full'>
<span className='text-white'>L1 Tx:</span>
<a
className='text-blue-500 underline'
target='_blank'
rel='noreferrer'
href={`https://goerli.etherscan.io/tx/${l1TxHash}`}
>
{`${l1TxHash?.slice(0, 8)}...`}
</a>
</div>
)}
{l2TxHash && (
<div className='flex flex-row justify-center space-x-8 items-center w-full'>
<span className='text-white'>Transaction:</span>
<span className='text-white'>L2 Tx:</span>
<a
className='text-blue-500 underline'
target='_blank'
rel='noreferrer'
href={`https://goerli.etherscan.io/tx/${data}`}
href={`https://goerli.basescan.org/tx/${l2TxHash}`}
>
{`${data?.slice(0, 8)}...`}
{`${l2TxHash?.slice(0, 8)}...`}
</a>
</div>
)}
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"typedoc-plugin-markdown": "^3.17.0",
"typescript": "5.0.4",
"vitest": "^0.34.1",
"wagmi": "alpha"
"wagmi": "beta",
"@tanstack/react-query": ">=5.0.0"
},
"scripts": {
"build": "pnpm run clean && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types",
Expand All @@ -87,19 +88,19 @@
"bench:ci": "CI=true vitest bench",
"dev:docs": "pnpm -r --filter docs dev",
"dev:example": "pnpm -r --filter example dev",
"dev:demo": "pnpm -r --filter demo dev",
"prepare": "npx simple-git-hooks"
},
"dependencies": {
"@eth-optimism/contracts-ts": "^0.15.0"
},
"peerDependencies": {
"@tanstack/query-core": ">=5.0.0",
"@tanstack/react-query": "beta",
"@wagmi/core": "alpha",
"@tanstack/react-query": ">=5.0.0",
"@wagmi/core": "beta",
"op-viem": "1.3.0-alpha",
"typescript": ">=5.0.4",
"viem": "2.0.0-alpha.17",
"wagmi": "alpha"
"viem": "2.0.0-beta.0",
"wagmi": "beta"
},
"peerDependenciesMeta": {
"typescript": {
Expand Down
Loading

0 comments on commit d05dd70

Please sign in to comment.