diff --git a/package.json b/package.json index 4133eb3..d0b74c6 100644 --- a/package.json +++ b/package.json @@ -23,17 +23,16 @@ "@chakra-ui/system": "^2.6.2", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.0", - "@ensdomains/content-hash": "^3.0.0", "@tanstack/react-query": "^5.25.0", "@tanstack/react-query-devtools": "^5.25.0", "adm-zip": "^0.5.10", "electron-log": "^5.1.2", "electron-squirrel-startup": "^1.0.0", + "ethers": "^6.11.1", "framer-motion": "^11.0.8", "react": "^18.2.0", "react-dom": "^18.2.0", "tar": "^6.2.0", - "viem": "^2.7.22", "zod": "^3.22.4" }, "devDependencies": { diff --git a/src/main.js b/src/main.js index bb98403..6775952 100644 --- a/src/main.js +++ b/src/main.js @@ -368,7 +368,7 @@ http 'Content-Length': response.headers.get('content-length'), 'Content-Type': response.headers.get('content-type'), }); - res.end(await response.buffer()); + res.end(Buffer.from(await response.arrayBuffer())); return; } } catch (e) { diff --git a/src/main/dapps.js b/src/main/dapps.js index 0660176..3231137 100644 --- a/src/main/dapps.js +++ b/src/main/dapps.js @@ -1,28 +1,10 @@ -import * as contentHash from '@ensdomains/content-hash'; import logger from 'electron-log'; -import { http, createPublicClient } from 'viem'; -import { mainnet } from 'viem/chains'; -import { namehash, normalize } from 'viem/ens'; +import { EnsResolver, getDefaultProvider } from 'ethers'; import { rpcRequest } from './ipfs'; export const DAPPS = []; -const client = createPublicClient({ - chain: mainnet, - transport: http(), -}); - -const resolverAbi = [ - { - constant: true, - inputs: [{ internalType: 'bytes32', name: 'node', type: 'bytes32' }], - name: 'contenthash', - outputs: [{ internalType: 'bytes', name: '', type: 'bytes' }], - payable: false, - stateMutability: 'view', - type: 'function', - }, -]; +const provider = getDefaultProvider(); export async function resolveEns(dapp) { if (dapp.ipns) { @@ -34,19 +16,20 @@ export async function resolveEns(dapp) { if (!dapp.ens) { throw new Error('Neither ipns nor ens was set, cannot resolve'); } - const name = normalize(dapp.ens); - const resolverAddress = await client.getEnsResolver({ name }); - const hash = await client.readContract({ - address: resolverAddress, - abi: resolverAbi, - functionName: 'contenthash', - args: [namehash(name)], - }); - const codec = contentHash.getCodec(hash); - return { - codec, - hash: contentHash.decode(hash), - }; + + const ensResolver = await EnsResolver.fromName(provider, dapp.ens); + + if (!ensResolver) { + throw new Error(`No resolver found for the ENS name: ${dapp.ens}`); + } + const contentHash = await ensResolver.getContentHash(); + + if (!contentHash) { + throw new Error(`No content hash found for the ENS name: ${dapp.ens}`); + } + const [codec, hash] = contentHash.split('://'); + + return { codec, hash }; } export async function resolveQm(ipns) { diff --git a/yarn.lock b/yarn.lock index 9cec920..dd2e49c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,10 +5,10 @@ __metadata: version: 8 cacheKey: 10 -"@adraffy/ens-normalize@npm:1.10.0": - version: 1.10.0 - resolution: "@adraffy/ens-normalize@npm:1.10.0" - checksum: 10/5cdb5d2a9c9f8c0a71a7bb830967da0069cae1f1235cd41ae11147e4000f368f6958386e622cd4d52bf45c1ed3f8275056b387cba28902b83354e40ff323ecde +"@adraffy/ens-normalize@npm:1.10.1": + version: 1.10.1 + resolution: "@adraffy/ens-normalize@npm:1.10.1" + checksum: 10/4cb938c4abb88a346d50cb0ea44243ab3574330c81d4f5aaaf9dfee584b96189d0faa404de0fcbef5a1b73909ea4ebc3e63d84bd23f9949e5c8d4085207a5091 languageName: node linkType: hard @@ -2281,16 +2281,6 @@ __metadata: languageName: node linkType: hard -"@ensdomains/content-hash@npm:^3.0.0": - version: 3.0.0 - resolution: "@ensdomains/content-hash@npm:3.0.0" - dependencies: - "@multiformats/sha3": "npm:^2.0.17" - multiformats: "npm:^12.0.1" - checksum: 10/95512a0175098ef70fbfa00cde66ea0665d4e182cf674bc4975f7b76ed95ab4d8df70b3dfb82af30bb9d72af08578316f13caf95f520658f3cefd5ff510c5dce - languageName: node - linkType: hard - "@gar/promisify@npm:^1.1.3": version: 1.1.3 resolution: "@gar/promisify@npm:1.1.3" @@ -2389,17 +2379,7 @@ __metadata: languageName: node linkType: hard -"@multiformats/sha3@npm:^2.0.17": - version: 2.0.17 - resolution: "@multiformats/sha3@npm:2.0.17" - dependencies: - js-sha3: "npm:^0.8.0" - multiformats: "npm:^9.5.4" - checksum: 10/970b444ae096be7d901d7fbc95809ed1748228262a19b41b3b746bd1fcfbd546e26782d4724c2ce4015cfe5da4b5fbc0acf68fe67ed47173cb84f18c3d490f38 - languageName: node - linkType: hard - -"@noble/curves@npm:1.2.0, @noble/curves@npm:~1.2.0": +"@noble/curves@npm:1.2.0": version: 1.2.0 resolution: "@noble/curves@npm:1.2.0" dependencies: @@ -2415,13 +2395,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:~1.3.0, @noble/hashes@npm:~1.3.2": - version: 1.3.3 - resolution: "@noble/hashes@npm:1.3.3" - checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d - languageName: node - linkType: hard - "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -2505,34 +2478,6 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.2": - version: 1.1.5 - resolution: "@scure/base@npm:1.1.5" - checksum: 10/543fa9991c6378b6a0d5ab7f1e27b30bb9c1e860d3ac81119b4213cfdf0ad7b61be004e06506e89de7ce0cec9391c17f5c082bb34c3b617a2ee6a04129f52481 - languageName: node - linkType: hard - -"@scure/bip32@npm:1.3.2": - version: 1.3.2 - resolution: "@scure/bip32@npm:1.3.2" - dependencies: - "@noble/curves": "npm:~1.2.0" - "@noble/hashes": "npm:~1.3.2" - "@scure/base": "npm:~1.1.2" - checksum: 10/b90da28dfe75519496a85c97e77c9443734873910f32b8557762910a5c4e642290a462b0ed14fa42e0efed6acb9a7f6155ad5cb5d38d4ff87eb2de4760eb32a4 - languageName: node - linkType: hard - -"@scure/bip39@npm:1.2.1": - version: 1.2.1 - resolution: "@scure/bip39@npm:1.2.1" - dependencies: - "@noble/hashes": "npm:~1.3.0" - "@scure/base": "npm:~1.1.0" - checksum: 10/2ea368bbed34d6b1701c20683bf465e147f231a9e37e639b8c82f585d6f978bb0f3855fca7ceff04954ae248b3e313f5d322d0210614fb7acb402739415aaf31 - languageName: node - linkType: hard - "@sindresorhus/is@npm:^4.0.0": version: 4.6.0 resolution: "@sindresorhus/is@npm:4.6.0" @@ -2821,6 +2766,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:18.15.13": + version: 18.15.13 + resolution: "@types/node@npm:18.15.13" + checksum: 10/b9bbe923573797ef7c5fd2641a6793489e25d9369c32aeadcaa5c7c175c85b42eb12d6fe173f6781ab6f42eaa1ebd9576a419eeaa2a1ec810094adb8adaa9a54 + languageName: node + linkType: hard + "@types/parse-json@npm:^4.0.0": version: 4.0.2 resolution: "@types/parse-json@npm:4.0.2" @@ -3133,21 +3085,6 @@ __metadata: languageName: node linkType: hard -"abitype@npm:1.0.0": - version: 1.0.0 - resolution: "abitype@npm:1.0.0" - peerDependencies: - typescript: ">=5.0.4" - zod: ^3 >=3.22.0 - peerDependenciesMeta: - typescript: - optional: true - zod: - optional: true - checksum: 10/38c8d965c75c031854385f1c14da0410e271f1a8255332869a77a1ee836c4607420522c1f0077716c7ad7c4091f53c1b2681ed1d30b5161d1424fdb5a480f104 - languageName: node - linkType: hard - "accepts@npm:~1.3.4, accepts@npm:~1.3.5, accepts@npm:~1.3.8": version: 1.3.8 resolution: "accepts@npm:1.3.8" @@ -3183,6 +3120,13 @@ __metadata: languageName: node linkType: hard +"aes-js@npm:4.0.0-beta.5": + version: 4.0.0-beta.5 + resolution: "aes-js@npm:4.0.0-beta.5" + checksum: 10/8f745da2e8fb38e91297a8ec13c2febe3219f8383303cd4ed4660ca67190242ccfd5fdc2f0d1642fd1ea934818fb871cd4cc28d3f28e812e3dc6c3d0f1f97c24 + languageName: node + linkType: hard + "agent-base@npm:6, agent-base@npm:^6.0.2": version: 6.0.2 resolution: "agent-base@npm:6.0.2" @@ -4821,6 +4765,21 @@ __metadata: languageName: node linkType: hard +"ethers@npm:^6.11.1": + version: 6.11.1 + resolution: "ethers@npm:6.11.1" + dependencies: + "@adraffy/ens-normalize": "npm:1.10.1" + "@noble/curves": "npm:1.2.0" + "@noble/hashes": "npm:1.3.2" + "@types/node": "npm:18.15.13" + aes-js: "npm:4.0.0-beta.5" + tslib: "npm:2.4.0" + ws: "npm:8.5.0" + checksum: 10/bfeba2670dbfdac3951a66ab2d5bbc18dd7e1be69da9142ad4fe3859a30891e7bb048ecbb6ab542b67df777ada1860445bb3dd83536219c0d3639fe05e74df8e + languageName: node + linkType: hard + "eventemitter3@npm:^4.0.0": version: 4.0.7 resolution: "eventemitter3@npm:4.0.7" @@ -6188,15 +6147,6 @@ __metadata: languageName: node linkType: hard -"isows@npm:1.0.3": - version: 1.0.3 - resolution: "isows@npm:1.0.3" - peerDependencies: - ws: "*" - checksum: 10/9cacd5cf59f67deb51e825580cd445ab1725ecb05a67c704050383fb772856f3cd5e7da8ad08f5a3bd2823680d77d099459d0c6a7037972a74d6429af61af440 - languageName: node - linkType: hard - "jackspeak@npm:^2.3.5": version: 2.3.6 resolution: "jackspeak@npm:2.3.6" @@ -6221,13 +6171,6 @@ __metadata: languageName: node linkType: hard -"js-sha3@npm:^0.8.0": - version: 0.8.0 - resolution: "js-sha3@npm:0.8.0" - checksum: 10/a49ac6d3a6bfd7091472a28ab82a94c7fb8544cc584ee1906486536ba1cb4073a166f8c7bb2b0565eade23c5b3a7b8f7816231e0309ab5c549b737632377a20c - languageName: node - linkType: hard - "js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" @@ -6964,20 +6907,6 @@ __metadata: languageName: node linkType: hard -"multiformats@npm:^12.0.1": - version: 12.1.3 - resolution: "multiformats@npm:12.1.3" - checksum: 10/b89ec581fc2b0fc567ca2b5450cc3f0f9ad56adf01b7b9780d07981d5177532be3296b22c1e415e0f17c6c6ddb9beece4ae2e14b79edfc5f3deacbd319a37516 - languageName: node - linkType: hard - -"multiformats@npm:^9.5.4": - version: 9.9.0 - resolution: "multiformats@npm:9.9.0" - checksum: 10/ad55c7d480d22f4258a68fd88aa2aab744fe0cb1e68d732fc886f67d858b37e3aa6c2cec12b2960ead7730d43be690931485238569952d8a3d7f90fdc726c652 - languageName: node - linkType: hard - "nanoid@npm:^3.3.7": version: 3.3.7 resolution: "nanoid@npm:3.3.7" @@ -8945,7 +8874,6 @@ __metadata: "@electron/fuses": "npm:^1.7.0" "@emotion/react": "npm:^11.11.4" "@emotion/styled": "npm:^11.11.0" - "@ensdomains/content-hash": "npm:^3.0.0" "@tanstack/react-query": "npm:^5.25.0" "@tanstack/react-query-devtools": "npm:^5.25.0" "@vercel/webpack-asset-relocator-loader": "npm:^1.7.3" @@ -8955,6 +8883,7 @@ __metadata: electron: "npm:^29.1.1" electron-log: "npm:^5.1.2" electron-squirrel-startup: "npm:^1.0.0" + ethers: "npm:^6.11.1" framer-motion: "npm:^11.0.8" node-loader: "npm:^2.0.0" react: "npm:^18.2.0" @@ -8962,7 +8891,6 @@ __metadata: style-loader: "npm:^3.3.4" svgo: "npm:^3.2.0" tar: "npm:^6.2.0" - viem: "npm:^2.7.22" webpack: "npm:^5.90.3" zod: "npm:^3.22.4" languageName: unknown @@ -9338,27 +9266,6 @@ __metadata: languageName: node linkType: hard -"viem@npm:^2.7.22": - version: 2.7.22 - resolution: "viem@npm:2.7.22" - dependencies: - "@adraffy/ens-normalize": "npm:1.10.0" - "@noble/curves": "npm:1.2.0" - "@noble/hashes": "npm:1.3.2" - "@scure/bip32": "npm:1.3.2" - "@scure/bip39": "npm:1.2.1" - abitype: "npm:1.0.0" - isows: "npm:1.0.3" - ws: "npm:8.13.0" - peerDependencies: - typescript: ">=5.0.4" - peerDependenciesMeta: - typescript: - optional: true - checksum: 10/2b4b8913ccf0a4b1ffc458581fd02ade73607158a36f736664860bd15c8a76cf437b8415adb554541f8f9260d8ffc227280d408a20460fc283875d50a11b30d6 - languageName: node - linkType: hard - "watchpack@npm:^2.4.0": version: 2.4.0 resolution: "watchpack@npm:2.4.0" @@ -9635,18 +9542,18 @@ __metadata: languageName: node linkType: hard -"ws@npm:8.13.0": - version: 8.13.0 - resolution: "ws@npm:8.13.0" +"ws@npm:8.5.0": + version: 8.5.0 + resolution: "ws@npm:8.5.0" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" + utf-8-validate: ^5.0.2 peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 10/1769532b6fdab9ff659f0b17810e7501831d34ecca23fd179ee64091dd93a51f42c59f6c7bb4c7a384b6c229aca8076fb312aa35626257c18081511ef62a161d + checksum: 10/f0ee700970a0bf925b1ec213ca3691e84fb8b435a91461fe3caf52f58c6cec57c99ed5890fbf6978824c932641932019aafc55d864cad38ac32577496efd5d3a languageName: node linkType: hard