From dd9f492185268b01db372a05c9970708035a5278 Mon Sep 17 00:00:00 2001 From: eericxu <2681350846@qq.com> Date: Fri, 12 Jul 2024 16:23:34 +0800 Subject: [PATCH] update blobtx --- app/blobtx/page.tsx | 26 +++++++------- next.config.js | 1 + package.json | 4 +-- pnpm-lock.yaml | 82 ++++++++++++++------------------------------- providers.tsx | 3 +- utils/wagmi.ts | 6 ++-- 6 files changed, 48 insertions(+), 74 deletions(-) diff --git a/app/blobtx/page.tsx b/app/blobtx/page.tsx index c4a3f9b..e351b44 100644 --- a/app/blobtx/page.tsx +++ b/app/blobtx/page.tsx @@ -48,7 +48,6 @@ const BlobTX = () => { const [isShow, setIsShow] = useState(true) const { disconnect } = useDisconnect() const [shownettip, setShowNetTip] = useState(false) - const { data: _wc } = useWalletClient({ chainId: ethda.id }) const { sendTransactionAsync } = useSendTransaction({}) const publicClient = usePublicClient({ chainId: ethda.id }) const [transData, setTransData] = useState<{ text: Uint8Array; img: Uint8Array; imgType: string }>() @@ -57,10 +56,10 @@ const BlobTX = () => { const [tempWc, setTempWc] = useState() useEffect(() => { setTempWc(cachedWallet()) - }) + }, []) const tempAccountAddrss = tempWc?.account?.address const validImageTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/svg+xml'] - const isConnected = account.address && account.isConnected && account.chainId == ethda.id + const isConnected = account.address && account.isConnected // console.info('isConnected', isConnected, account.address, account.isConnected, account.chain?.id, ethda.id) const clearAllState = () => { setLoading({ loading: false, success: false, error: false, errorMsg: '', uploadImageError: '' }) @@ -104,7 +103,6 @@ const BlobTX = () => { }) } - useEffect(() => { if (!isConnected) { clearAllState() @@ -256,23 +254,21 @@ const BlobTX = () => { } const onSendTx = async () => { - if (!_wc || !transData || !publicClient || !account || !account.address) return + if (!transData || !publicClient || !account || !account.address) return try { setLoading({ loading: true }) const walletClient = tempWc ?? cachedWallet() const sender: Address = walletClient.account?.address as any const balance = await publicClient.getBalance({ address: sender }) - if (balance < parseEther('0.0001')) { - const hash = await sendTransactionAsync({ account: account.address, to: sender, value: parseEther('0.001') }) + if (balance < parseEther('0.0006')) { + const hash = await sendTransactionAsync({ chainId: ethda.id, account: account.address, to: sender, value: parseEther('0.001') }) await publicClient.waitForTransactionReceipt({ hash, confirmations: 3 }) // return setLoading({ loading: false, error: true, errorMsg: 'Insufficient funds for gas' }) } const blobs = [transData.text, transData.img] const { commitments, proofs, versionHashs, encodeBlobs } = await getConvertOfZkg(blobs) const blobBaseFee = await publicClient.getBlobBaseFee() - const perGas = await publicClient.estimateFeesPerGas({ type: 'eip4844' }) - - console.info('blobBaseFee', blobBaseFee, (perGas.gasPrice ?? 1n) * BigInt(blobs.length) * 128n * 1024n) + console.info('blobBaseFee', blobBaseFee) const blobsMeta = createMetaDataForBlobs(sender, [ { content_type: 'text/plain', @@ -306,8 +302,9 @@ const BlobTX = () => { chain: ethda, }) console.info('tx:', request.gas, request.gasPrice, request.maxPriorityFeePerGas) - - const res = await walletClient.signTransaction(request as any) + // @ts-ignore + const res = await walletClient.account.signTransaction(request) + // const res = await walletClient.signTransaction(request as any) const hexSig = (res.startsWith('0x') ? res : `0x${res}`) as `0x${string}` const transaction = parseTransaction(hexSig) if (!transaction) return @@ -451,7 +448,10 @@ const BlobTX = () => { {tempWc && (
- BlobTx Account: {formatEthereumAddress(tempWc.account?.address)} + BlobTx Account:{' '} + + {formatEthereumAddress(tempWc.account?.address)} +
)} diff --git a/next.config.js b/next.config.js index 5bc5a2d..70e8853 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + // reactStrictMode: false, output: 'export', webpack: (config) => { config.resolve.fallback = { fs: false, net: false, tls: false } diff --git a/package.json b/package.json index d70c009..80e6838 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ "slick-carousel": "^1.8.1", "styled-components": "^6.1.8", "tailwind-merge": "^2.2.1", - "viem": "~2.14.2", - "wagmi": "~2.10.2" + "viem": "2.14.x", + "wagmi": "2.10.x" }, "browser": { "fs": false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7c9ca7..9616d3d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,10 +114,10 @@ dependencies: specifier: ^2.2.1 version: 2.2.1 viem: - specifier: ~2.14.2 + specifier: 2.14.x version: 2.14.2(typescript@5.3.3) wagmi: - specifier: ~2.10.2 + specifier: 2.10.x version: 2.10.2(@tanstack/react-query@5.45.1)(@types/react@18.2.48)(react-dom@18.2.0)(react-i18next@13.5.0)(react-native@0.74.2)(react@18.2.0)(typescript@5.3.3)(viem@2.14.2) devDependencies: @@ -1883,7 +1883,7 @@ packages: clsx: 1.2.1 eventemitter3: 5.0.1 keccak: 3.0.4 - preact: 10.19.3 + preact: 10.22.0 sha.js: 2.4.11 dev: false @@ -2616,7 +2616,7 @@ packages: bufferutil: 4.0.8 cross-fetch: 4.0.0 date-fns: 2.30.0 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.5 eciesjs: 0.3.19 eventemitter2: 6.4.9 readable-stream: 3.6.2 @@ -2669,7 +2669,7 @@ packages: '@types/dom-screen-wake-lock': 1.0.3 bowser: 2.11.0 cross-fetch: 4.0.0 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.5 eciesjs: 0.3.19 eth-rpc-errors: 4.0.3 eventemitter2: 6.4.9 @@ -2735,9 +2735,9 @@ packages: '@noble/hashes': 1.3.3 '@scure/base': 1.1.5 '@types/debug': 4.1.12 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.5 pony-cause: 2.1.11 - semver: 7.5.4 + semver: 7.6.2 uuid: 9.0.1 transitivePeerDependencies: - supports-color @@ -2997,7 +2997,6 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] - libc: [glibc] requiresBuild: true dev: false optional: true @@ -3007,7 +3006,6 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] - libc: [glibc] requiresBuild: true dev: false optional: true @@ -3017,7 +3015,6 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] - libc: [musl] requiresBuild: true dev: false optional: true @@ -3027,7 +3024,6 @@ packages: engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] - libc: [glibc] requiresBuild: true dev: false optional: true @@ -3037,7 +3033,6 @@ packages: engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] - libc: [musl] requiresBuild: true dev: false optional: true @@ -3047,7 +3042,7 @@ packages: engines: {node: '>= 10.0.0'} dependencies: is-glob: 4.0.3 - micromatch: 4.0.5 + micromatch: 4.0.7 napi-wasm: 1.1.0 dev: false bundledDependencies: @@ -3086,7 +3081,7 @@ packages: dependencies: detect-libc: 1.0.3 is-glob: 4.0.3 - micromatch: 4.0.5 + micromatch: 4.0.7 node-addon-api: 7.1.0 optionalDependencies: '@parcel/watcher-android-arm64': 2.4.0 @@ -4371,7 +4366,7 @@ packages: /@types/secp256k1@4.0.6: resolution: {integrity: sha512-hHxJU6PAEUn0TP4S/ZOzuTUvJWuZ6eIKeNKb5RBpODvSl6hp1Wrw4s7ATY50rklRCScUDpHzVA/DQdSjJ3UoYQ==} dependencies: - '@types/node': 20.11.5 + '@types/node': 20.14.2 dev: false /@types/stack-utils@2.0.3: @@ -4627,13 +4622,6 @@ packages: events: 3.3.0 dev: false - /@walletconnect/jsonrpc-types@1.0.3: - resolution: {integrity: sha512-iIQ8hboBl3o5ufmJ8cuduGad0CQm3ZlsHtujv9Eu16xq89q+BG7Nh5VLxxUgmtpnrePgFkTwXirCTkwJH1v+Yw==} - dependencies: - keyvaluestorage-interface: 1.0.0 - tslib: 1.14.1 - dev: false - /@walletconnect/jsonrpc-types@1.0.4: resolution: {integrity: sha512-P6679fG/M+wuWg9TY8mh6xFSdYnFyFjwFelxyISxMDrlbXokorEVXYOxiqEbrU3x1BmBoCAJJ+vtEaEoMlpCBQ==} dependencies: @@ -4645,7 +4633,7 @@ packages: resolution: {integrity: sha512-vdeb03bD8VzJUL6ZtzRYsFMq1eZQcM3EAzT0a3st59dyLfJ0wq+tKMpmGH7HlB7waD858UWgfIcudbPFsbzVdw==} dependencies: '@walletconnect/environment': 1.0.1 - '@walletconnect/jsonrpc-types': 1.0.3 + '@walletconnect/jsonrpc-types': 1.0.4 tslib: 1.14.1 dev: false @@ -4655,7 +4643,7 @@ packages: '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/safe-json': 1.0.2 events: 3.3.0 - ws: 7.5.9 + ws: 7.5.10 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -4942,12 +4930,6 @@ packages: negotiator: 0.6.3 dev: false - /acorn@8.11.3: - resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} - engines: {node: '>=0.4.0'} - hasBin: true - dev: false - /acorn@8.12.0: resolution: {integrity: sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==} engines: {node: '>=0.4.0'} @@ -6281,7 +6263,7 @@ packages: resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==} engines: {node: '>=0.11'} dependencies: - '@babel/runtime': 7.23.8 + '@babel/runtime': 7.24.7 dev: false /dateformat@4.6.3: @@ -6556,7 +6538,7 @@ packages: resolution: {integrity: sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==} dependencies: '@socket.io/component-emitter': 3.1.2 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.5 engine.io-parser: 5.2.2 ws: 8.11.0 xmlhttprequest-ssl: 2.0.0 @@ -6650,6 +6632,7 @@ packages: /escalade@3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} + dev: true /escalade@3.1.2: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} @@ -7708,13 +7691,13 @@ packages: /i18next-browser-languagedetector@7.1.0: resolution: {integrity: sha512-cr2k7u1XJJ4HTOjM9GyOMtbOA47RtUoWRAtt52z43r3AoMs2StYKyjS3URPhzHaf+mn10hY9dZWamga5WPQjhA==} dependencies: - '@babel/runtime': 7.23.8 + '@babel/runtime': 7.24.7 dev: false /i18next@22.5.1: resolution: {integrity: sha512-8TGPgM3pAD+VRsMtUMNknRz3kzqwp/gPALrWMsDnmC1mKqJwpWyooQRLMcbTwq8z8YwSmuj+ZYvc+xCuEpkssA==} dependencies: - '@babel/runtime': 7.23.8 + '@babel/runtime': 7.24.7 dev: false /idb-keyval@6.2.1: @@ -7811,7 +7794,7 @@ packages: dependencies: '@ioredis/commands': 1.2.0 cluster-key-slot: 1.1.2 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.5 denque: 2.1.0 lodash.defaults: 4.2.0 lodash.isarguments: 3.1.0 @@ -8114,12 +8097,12 @@ packages: - encoding dev: false - /isomorphic-ws@4.0.1(ws@7.5.9): + /isomorphic-ws@4.0.1(ws@7.5.10): resolution: {integrity: sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==} peerDependencies: ws: '*' dependencies: - ws: 7.5.9 + ws: 7.5.10 dev: false /isows@1.0.3(ws@8.13.0): @@ -8164,10 +8147,10 @@ packages: delay: 5.0.0 es6-promisify: 5.0.0 eyes: 0.1.8 - isomorphic-ws: 4.0.1(ws@7.5.9) + isomorphic-ws: 4.0.1(ws@7.5.10) json-stringify-safe: 5.0.1 uuid: 8.3.2 - ws: 7.5.9 + ws: 7.5.10 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -9196,7 +9179,7 @@ packages: /mlly@1.5.0: resolution: {integrity: sha512-NPVQvAY1xr1QoVeG0cy8yUYC7FQcOx6evl/RjT1wL5FvzPnzOysoqB/jmx/DhssT2dYa8nxECLAaFI/+gVLhDQ==} dependencies: - acorn: 8.11.3 + acorn: 8.12.0 pathe: 1.1.2 pkg-types: 1.0.3 ufo: 1.3.2 @@ -11269,7 +11252,7 @@ packages: engines: {node: '>=10.0.0'} dependencies: '@socket.io/component-emitter': 3.1.2 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.5 engine.io-client: 6.5.3 socket.io-parser: 4.2.4 transitivePeerDependencies: @@ -11283,7 +11266,7 @@ packages: engines: {node: '>=10.0.0'} dependencies: '@socket.io/component-emitter': 3.1.2 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.5 transitivePeerDependencies: - supports-color dev: false @@ -12720,19 +12703,6 @@ packages: optional: true dev: false - /ws@7.5.9: - resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} - engines: {node: '>=8.3.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: false - /ws@8.11.0: resolution: {integrity: sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==} engines: {node: '>=10.0.0'} @@ -12852,7 +12822,7 @@ packages: engines: {node: '>=12'} dependencies: cliui: 8.0.1 - escalade: 3.1.1 + escalade: 3.1.2 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 diff --git a/providers.tsx b/providers.tsx index 22fcf32..7312b82 100644 --- a/providers.tsx +++ b/providers.tsx @@ -10,10 +10,11 @@ import { withClient } from './components/withClient' const queryClient = new QueryClient() export const Providers = withClient(({ children }: { children: ReactNode }) => { + console.info('Providers Changed') return ( - + {children} diff --git a/utils/wagmi.ts b/utils/wagmi.ts index 46712de..be6b50b 100644 --- a/utils/wagmi.ts +++ b/utils/wagmi.ts @@ -28,7 +28,9 @@ export const ethda = defineChain({ }, }, contracts: { - blobTo: { address: '0x975ef84AE286F95a9F732C30267Bb50D103b4374' }, + // blobTo: { address: '0x9FC2d50067AC5B732cA4D02a2d1A8F286882D909' }, + // blobTo: { address: zeroAddress }, + blobTo: { address: '0xCC0BC5927905ba756659A0c4e90A6dcD626416ee' }, }, custom: { bridgeUrl: 'https://bridge-testnet.ethda.io', @@ -56,7 +58,7 @@ export const ethda = defineChain({ }) import { metaMaskWallet, tokenPocketWallet, walletConnectWallet } from '@rainbow-me/rainbowkit/wallets' -import { createClient } from 'viem' +import { createClient, zeroAddress } from 'viem' const connectors = connectorsForWallets([{ groupName: 'Suggested', wallets: [metaMaskWallet, tokenPocketWallet, walletConnectWallet] }], { appName: 'EthDA', appUrl: 'https://ethda.io',