diff --git a/.gitmodules b/.gitmodules index b1d1263..3ee2444 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "trustwallet"] path = trustwallet url = https://github.com/trustwallet/assets.git +[submodule "topic0"] + path = topic0 + url = https://github.com/wmitsuda/topic0.git diff --git a/4bytes b/4bytes index 1cc7e25..2053752 160000 --- a/4bytes +++ b/4bytes @@ -1 +1 @@ -Subproject commit 1cc7e25c840ae9d985c12768b0cbd0ece3fc5400 +Subproject commit 20537524bfb01bee859c9cfa9a8784baacbcc7ae diff --git a/Dockerfile b/Dockerfile index af322ed..e113ddb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,13 @@ WORKDIR /signatures COPY 4bytes/signatures /signatures/ COPY 4bytes/with_parameter_names /signatures/ +FROM alpine:3.14.0 AS topic0builder +WORKDIR /topic0 +COPY topic0/with_parameter_names /topic0/ + FROM nginx:1.21.1-alpine RUN apk add jq +COPY --from=topic0builder /topic0 /usr/share/nginx/html/topic0/ COPY --from=fourbytesbuilder /signatures /usr/share/nginx/html/signatures/ COPY --from=logobuilder /assets /usr/share/nginx/html/assets/ COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/docs/ipfs.md b/docs/ipfs.md new file mode 100644 index 0000000..117ed18 --- /dev/null +++ b/docs/ipfs.md @@ -0,0 +1,65 @@ +# IPFS + +This doc describes various topics regarding our use of IPFS (currently only used for Sourcify integration). + +## Default public gateway by default + +By default every IPFS resource is linked to the default public IPFS gateway at https://ipfs.io. + +This is done so even users without a local node can use IPFS integration by default. + +However this brings us some privacy concerns, since queries are made against the public gateway. + +We recommend the use of [IPFS Companion](https://docs.ipfs.io/install/ipfs-companion/), a popular browser extension that intercepts gateway calls and redirect them to your local gateway. + +This also solves the problem of users not having a local gateway at http://localhost:8080 (the default bind address of `ipfs` daemon, but also a very common bind address for other software leading to collisions), but instead having a private gateway inside the local network. The IPFS Companion allows you to customize which gateway you want it to redirect requests to. + +This way we can provide an out-of-box usable integration, but still allowing users to address privacy concerns. + +## Slow IPNS resolution + +By default IPNS resolution _may_ be **extremelly** slow. There is an experimental IPFS feature called IPNS pubsub that speeds it up significantly (https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipns-pubsub), but for it to work, it needs to be enabled in **both** resolver and publisher nodes. + +We asked Sourcify to enable it in their publisher node, so you just have to enable it in your local node to have an usable performance. + +On IPFS Companion, make sure **both** `Enable PubSub` and `Enable IPNS over PubSub` options are enabled. + +![IPFS pubsub](./ipns-pubsub.png) + +## Pinning Sourcify locally + +If you have an IPFS node, you can speedup things significantly and also help to spread their data among the network by pinning their entire repository. + +However, due to their repository characteristics (> 5 GB of thousands of small files and many nested directories), there are a few gotchas. + +> Please note this is based on Otterscan author's experience, it would be welcome to have more datapoints. + +### Use `badgerds` + +By default ipfs uses the `flatfs` datastore, which stores objects in simple files. + +I simply couldn't finish pinning the entire repo using the default settings, after 6 hours it was able to get only ~10% of the total repo, the pinning process itself slows down the computer a lot. + +`badgerds` is an alternative ipfs node repository format, still labeled as experimental, but marked as a _"to be turned into the default"_ repository format in future. It uses a key-value database internally. + +You can create a repository from scratch by using `ipfs init -p badgerds`, or convert an existing repository using [ipfs-ds-convert](https://github.com/ipfs/ipfs-ds-convert). + +> Use it at your own risk! + +My experiments pinning the entire repo on `badgerds` gave different timings, varying from 1 to 2 hours in a standard MacBook Pro laptop, totally affordable for home users, with no perceived system degradation. + +``` +$ time ipfs pin add --progress /ipns/k51qzi5uqu5dll0ocge71eudqnrgnogmbr37gsgl12uubsinphjoknl6bbi41p +pinned QmVn7fcwo4Eai19hRX6dG9jAV8piHyxcrPTuobyZjEKhMW recursively +ipfs pin add --progress 4.47s user 1.85s system 0% cpu 2:22:41.00 total +``` + +### IPFS root changes hourly + +The Sourcify root IPNS name is `/ipns/k51qzi5uqu5dll0ocge71eudqnrgnogmbr37gsgl12uubsinphjoknl6bbi41p`. + +Pinning it resolves it to the current IPFS root hash. However, any change to their contents changes the root hash (e.g., new contracts are verified). + +Sourcify current runs a cron job the updates the IPNS name hourly. It means that your pin will eventually become stale. + +But we think it is still worth pinning the repo because data always gets added to their repo, so by pinning current data you are speeding up your own queries to existing contracts and contributing to spread their data over the network so other people don't have to rely 100% on their node availability. diff --git a/docs/ipns-pubsub.png b/docs/ipns-pubsub.png new file mode 100644 index 0000000..2d81642 Binary files /dev/null and b/docs/ipns-pubsub.png differ diff --git a/docs/sourcify.md b/docs/sourcify.md index cede6d3..6159519 100644 --- a/docs/sourcify.md +++ b/docs/sourcify.md @@ -2,32 +2,32 @@ We get the contract source code and metadata from [Sourcify](https://sourcify.dev/). -There are multiple ways to consume their data we support, each one with pros and cons: +## Integration modes -## IPNS/IPFS +There are multiple ways to consume their data that we support, each one with pros and cons: + +### IPFS This is the default integration method, we resolve the public Sourcify IPNS to get the latest known IPFS root hash of their repository. The downside is that recently verified contracts may not have yet been added to the root hash and republished into IPNS. -It assumes a local IPFS gateway at localhost:8080 to avoid leaking your queries to public gateways. +It uses the public gateway at https://ipfs.io by default. -> This option is actually not working, but it is provided for completeness, follow https://github.com/ethereum/sourcify/issues/495 +Please see our [ipfs integration docs](./ipfs.md) for more info about how we handle all IPFS integrations and privacy concerns. -## Direct HTTP connection to Sourcify's repository +### Direct HTTP connection to Sourcify's repository Standard HTTP connection to their repo at https://repo.sourcify.dev/ Fast access to fresh verified data. On the other hand it is less private and centralized. -## Local snapshot +### Local snapshot **(deprecated; soon to be removed)** As a midterm solution, we are making available a snapshot docker image of their repository, containing only mainnet full verified contracts. This would allow you to play with existing contracts up to the snapshot date/time locally, not depending on their service or IPFS connectivity availability. -> It is very likely this run mode will be deprecated in future. - The Sourcify snapshot is provided as a nginx image at: https://hub.docker.com/repository/docker/otterscan/sourcify-snapshot You can run it with: diff --git a/nginx.conf b/nginx.conf index 55189ba..932cfeb 100644 --- a/nginx.conf +++ b/nginx.conf @@ -43,6 +43,40 @@ server { } } + location /topic0 { + root /usr/share/nginx/html; + expires 30d; + + # Base on: https://michielkalkman.com/snippets/nginx-cors-open-configuration/ + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + # + # Om nom nom cookies + # + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; + + # + # Custom headers and headers various browsers *should* be OK with but aren't + # + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + + # + # Tell client that this pre-flight info is valid for 20 days + # + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always; + } + } + location /assets { root /usr/share/nginx/html; expires 30d; diff --git a/package-lock.json b/package-lock.json index 495f958..178efba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,18 +20,18 @@ "@fortawesome/free-brands-svg-icons": "^5.15.4", "@fortawesome/free-regular-svg-icons": "^5.15.4", "@fortawesome/free-solid-svg-icons": "^5.15.4", - "@fortawesome/react-fontawesome": "^0.1.15", + "@fortawesome/react-fontawesome": "^0.1.16", "@headlessui/react": "^1.4.1", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.24", "@types/node": "^14.17.5", - "@types/react": "^17.0.26", + "@types/react": "^17.0.30", "@types/react-blockies": "^1.4.1", "@types/react-dom": "^17.0.9", - "@types/react-highlight": "^0.12.4", - "@types/react-router-dom": "^5.3.0", + "@types/react-highlight": "^0.12.5", + "@types/react-router-dom": "^5.3.1", "@types/react-syntax-highlighter": "^13.5.2", "chart.js": "^3.5.1", "ethers": "^5.4.7", @@ -47,13 +47,13 @@ "react-scripts": "4.0.3", "react-syntax-highlighter": "^15.4.4", "serve": "^12.0.1", - "typescript": "^4.4.3", + "typescript": "^4.4.4", "use-keyboard-shortcut": "^1.0.6", "web-vitals": "^1.0.1" }, "devDependencies": { - "autoprefixer": "^9.8.7", - "postcss": "^7.0.38", + "autoprefixer": "^9.8.8", + "postcss": "^7.0.39", "source-map-explorer": "^2.5.2", "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.6" } @@ -2089,14 +2089,14 @@ } }, "node_modules/@fortawesome/react-fontawesome": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.15.tgz", - "integrity": "sha512-/HFHdcoLESxxMkqZAcZ6RXDJ69pVApwdwRos/B2kiMWxDSAX2dFK8Er2/+rG+RsrzWB/dsAyjefLmemgmfE18g==", + "version": "0.1.16", + "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.16.tgz", + "integrity": "sha512-aLmzDwC9rEOAJv2UJdMns89VZR5Ry4IHu5dQQh24Z/lWKEm44lfQr1UNalZlkUaQN8d155tNh+CS7ntntj1VMA==", "dependencies": { "prop-types": "^15.7.2" }, "peerDependencies": { - "@fortawesome/fontawesome-svg-core": "^1.2.32", + "@fortawesome/fontawesome-svg-core": "~1 || >=1.3.0-beta1", "react": ">=16.x" } }, @@ -3090,9 +3090,9 @@ "license": "MIT" }, "node_modules/@types/react": { - "version": "17.0.26", - "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz", - "integrity": "sha512-MXxuXrH2xOcv5cp/su4oz69dNQnSA90JjFw5HBd5wifw6Ihi94j7dRJm7qNsB30tnruXSCPc9qmlhGop4nh9Hw==", + "version": "17.0.30", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.30.tgz", + "integrity": "sha512-3Dt/A8gd3TCXi2aRe84y7cK1K8G+N9CZRDG8kDGguOKa0kf/ZkSwTmVIDPsm/KbQOVMaDJXwhBtuOXxqwdpWVg==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -3116,9 +3116,9 @@ } }, "node_modules/@types/react-highlight": { - "version": "0.12.4", - "resolved": "https://registry.npmjs.org/@types/react-highlight/-/react-highlight-0.12.4.tgz", - "integrity": "sha512-eq+1LUJYDTpZMx31KD3e8K0OJcfUlgWaxYGldKfD7uMkmg04x6O2+h6kG7Rm0SY1+XkeBWYhg2lyIFv8WpGrLQ==", + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/@types/react-highlight/-/react-highlight-0.12.5.tgz", + "integrity": "sha512-P8+mTxltxDdQ+99l+pjn40clziSbNrZy5d5zmvG+j3jKzokAhCoCZlIRmmnFgETTYubuqwKjvXSlvesBZcTfvQ==", "dependencies": { "@types/react": "*" } @@ -3133,9 +3133,9 @@ } }, "node_modules/@types/react-router-dom": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/@types/react-router-dom/-/react-router-dom-5.3.0.tgz", - "integrity": "sha512-svUzpEpKDwK8nmfV2vpZNSsiijFNKY8+gUqGqvGGOVrXvX58k1JIJubZa5igkwacbq/0umphO5SsQn/BQsnKpw==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@types/react-router-dom/-/react-router-dom-5.3.1.tgz", + "integrity": "sha512-UvyRy73318QI83haXlaMwmklHHzV9hjl3u71MmM6wYNu0hOVk9NLTa0vGukf8zXUqnwz4O06ig876YSPpeK28A==", "dependencies": { "@types/history": "*", "@types/react": "*", @@ -4163,15 +4163,15 @@ } }, "node_modules/autoprefixer": { - "version": "9.8.7", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.8.7.tgz", - "integrity": "sha512-7Hg99B1eTH5+LgmUBUSmov1Z3bsggQJS7v3IMGo6wcScnbRuvtMc871J9J+4bSbIqa9LSX/zypFXJ8sXHpMJeQ==", + "version": "9.8.8", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.8.8.tgz", + "integrity": "sha512-eM9d/swFopRt5gdJ7jrpCwgvEMIayITpojhkkSMRsFHYuH5bkSQ4p/9qTEHtmNudUZh22Tehu7I6CxAW0IXTKA==", "dependencies": { "browserslist": "^4.12.0", "caniuse-lite": "^1.0.30001109", - "nanocolors": "^0.2.8", "normalize-range": "^0.1.2", "num2fraction": "^1.2.2", + "picocolors": "^0.2.1", "postcss": "^7.0.32", "postcss-value-parser": "^4.1.0" }, @@ -11883,11 +11883,6 @@ "license": "MIT", "optional": true }, - "node_modules/nanocolors": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/nanocolors/-/nanocolors-0.2.10.tgz", - "integrity": "sha512-i+EDWGsJClQwR/bhLIG/CObZZwaYaS5qt+yjxZbfV+77QiNHNzE9nj4d9Ut1TGZ0R0eSwPcQWzReASzXuw/7oA==" - }, "node_modules/nanoid": { "version": "3.1.23", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", @@ -12728,6 +12723,11 @@ "version": "2.1.0", "license": "MIT" }, + "node_modules/picocolors": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-0.2.1.tgz", + "integrity": "sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA==" + }, "node_modules/picomatch": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", @@ -12896,11 +12896,11 @@ } }, "node_modules/postcss": { - "version": "7.0.38", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.38.tgz", - "integrity": "sha512-wNrSHWjHDQJR/IZL5IKGxRtFgrYNaAA/UrkW2WqbtZO6uxSLMxMN+s2iqUMwnAWm3fMROlDYZB41dr0Mt7vBwQ==", + "version": "7.0.39", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.39.tgz", + "integrity": "sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA==", "dependencies": { - "nanocolors": "^0.2.2", + "picocolors": "^0.2.1", "source-map": "^0.6.1" }, "engines": { @@ -18161,9 +18161,9 @@ } }, "node_modules/typescript": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", - "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -20969,9 +20969,9 @@ } }, "@fortawesome/react-fontawesome": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.15.tgz", - "integrity": "sha512-/HFHdcoLESxxMkqZAcZ6RXDJ69pVApwdwRos/B2kiMWxDSAX2dFK8Er2/+rG+RsrzWB/dsAyjefLmemgmfE18g==", + "version": "0.1.16", + "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.16.tgz", + "integrity": "sha512-aLmzDwC9rEOAJv2UJdMns89VZR5Ry4IHu5dQQh24Z/lWKEm44lfQr1UNalZlkUaQN8d155tNh+CS7ntntj1VMA==", "requires": { "prop-types": "^15.7.2" } @@ -21619,9 +21619,9 @@ "version": "1.5.4" }, "@types/react": { - "version": "17.0.26", - "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz", - "integrity": "sha512-MXxuXrH2xOcv5cp/su4oz69dNQnSA90JjFw5HBd5wifw6Ihi94j7dRJm7qNsB30tnruXSCPc9qmlhGop4nh9Hw==", + "version": "17.0.30", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.30.tgz", + "integrity": "sha512-3Dt/A8gd3TCXi2aRe84y7cK1K8G+N9CZRDG8kDGguOKa0kf/ZkSwTmVIDPsm/KbQOVMaDJXwhBtuOXxqwdpWVg==", "requires": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -21645,9 +21645,9 @@ } }, "@types/react-highlight": { - "version": "0.12.4", - "resolved": "https://registry.npmjs.org/@types/react-highlight/-/react-highlight-0.12.4.tgz", - "integrity": "sha512-eq+1LUJYDTpZMx31KD3e8K0OJcfUlgWaxYGldKfD7uMkmg04x6O2+h6kG7Rm0SY1+XkeBWYhg2lyIFv8WpGrLQ==", + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/@types/react-highlight/-/react-highlight-0.12.5.tgz", + "integrity": "sha512-P8+mTxltxDdQ+99l+pjn40clziSbNrZy5d5zmvG+j3jKzokAhCoCZlIRmmnFgETTYubuqwKjvXSlvesBZcTfvQ==", "requires": { "@types/react": "*" } @@ -21662,9 +21662,9 @@ } }, "@types/react-router-dom": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/@types/react-router-dom/-/react-router-dom-5.3.0.tgz", - "integrity": "sha512-svUzpEpKDwK8nmfV2vpZNSsiijFNKY8+gUqGqvGGOVrXvX58k1JIJubZa5igkwacbq/0umphO5SsQn/BQsnKpw==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@types/react-router-dom/-/react-router-dom-5.3.1.tgz", + "integrity": "sha512-UvyRy73318QI83haXlaMwmklHHzV9hjl3u71MmM6wYNu0hOVk9NLTa0vGukf8zXUqnwz4O06ig876YSPpeK28A==", "requires": { "@types/history": "*", "@types/react": "*", @@ -22342,15 +22342,15 @@ "version": "2.1.2" }, "autoprefixer": { - "version": "9.8.7", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.8.7.tgz", - "integrity": "sha512-7Hg99B1eTH5+LgmUBUSmov1Z3bsggQJS7v3IMGo6wcScnbRuvtMc871J9J+4bSbIqa9LSX/zypFXJ8sXHpMJeQ==", + "version": "9.8.8", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.8.8.tgz", + "integrity": "sha512-eM9d/swFopRt5gdJ7jrpCwgvEMIayITpojhkkSMRsFHYuH5bkSQ4p/9qTEHtmNudUZh22Tehu7I6CxAW0IXTKA==", "requires": { "browserslist": "^4.12.0", "caniuse-lite": "^1.0.30001109", - "nanocolors": "^0.2.8", "normalize-range": "^0.1.2", "num2fraction": "^1.2.2", + "picocolors": "^0.2.1", "postcss": "^7.0.32", "postcss-value-parser": "^4.1.0" }, @@ -27527,11 +27527,6 @@ "version": "2.14.2", "optional": true }, - "nanocolors": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/nanocolors/-/nanocolors-0.2.10.tgz", - "integrity": "sha512-i+EDWGsJClQwR/bhLIG/CObZZwaYaS5qt+yjxZbfV+77QiNHNzE9nj4d9Ut1TGZ0R0eSwPcQWzReASzXuw/7oA==" - }, "nanoid": { "version": "3.1.23", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", @@ -28076,6 +28071,11 @@ "performance-now": { "version": "2.1.0" }, + "picocolors": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-0.2.1.tgz", + "integrity": "sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA==" + }, "picomatch": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", @@ -28182,11 +28182,11 @@ "version": "0.1.1" }, "postcss": { - "version": "7.0.38", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.38.tgz", - "integrity": "sha512-wNrSHWjHDQJR/IZL5IKGxRtFgrYNaAA/UrkW2WqbtZO6uxSLMxMN+s2iqUMwnAWm3fMROlDYZB41dr0Mt7vBwQ==", + "version": "7.0.39", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.39.tgz", + "integrity": "sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA==", "requires": { - "nanocolors": "^0.2.2", + "picocolors": "^0.2.1", "source-map": "^0.6.1" } }, @@ -31844,9 +31844,9 @@ } }, "typescript": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", - "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==" + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==" }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4" diff --git a/package.json b/package.json index ad60da8..3b0c375 100644 --- a/package.json +++ b/package.json @@ -15,18 +15,18 @@ "@fortawesome/free-brands-svg-icons": "^5.15.4", "@fortawesome/free-regular-svg-icons": "^5.15.4", "@fortawesome/free-solid-svg-icons": "^5.15.4", - "@fortawesome/react-fontawesome": "^0.1.15", + "@fortawesome/react-fontawesome": "^0.1.16", "@headlessui/react": "^1.4.1", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.24", "@types/node": "^14.17.5", - "@types/react": "^17.0.26", + "@types/react": "^17.0.30", "@types/react-blockies": "^1.4.1", "@types/react-dom": "^17.0.9", - "@types/react-highlight": "^0.12.4", - "@types/react-router-dom": "^5.3.0", + "@types/react-highlight": "^0.12.5", + "@types/react-router-dom": "^5.3.1", "@types/react-syntax-highlighter": "^13.5.2", "chart.js": "^3.5.1", "ethers": "^5.4.7", @@ -42,7 +42,7 @@ "react-scripts": "4.0.3", "react-syntax-highlighter": "^15.4.4", "serve": "^12.0.1", - "typescript": "^4.4.3", + "typescript": "^4.4.4", "use-keyboard-shortcut": "^1.0.6", "web-vitals": "^1.0.1" }, @@ -52,8 +52,8 @@ "test": "craco test", "eject": "react-scripts eject", "source-map-explorer": "source-map-explorer build/static/js/*.js", - "assets-start": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets -v$(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", - "assets-start-with-param-names": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/with_parameter_names:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets -v$(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", + "assets-start": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", + "assets-start-with-param-names": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/with_parameter_names:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", "assets-stop": "docker stop otterscan-assets", "docker-build": "DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile .", "docker-start": "docker run --rm -p 5000:80 --name otterscan -d otterscan", @@ -78,8 +78,8 @@ ] }, "devDependencies": { - "autoprefixer": "^9.8.7", - "postcss": "^7.0.38", + "autoprefixer": "^9.8.8", + "postcss": "^7.0.39", "source-map-explorer": "^2.5.2", "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.6" } diff --git a/public/sourcify.svg b/public/sourcify.svg new file mode 100644 index 0000000..b9e2156 --- /dev/null +++ b/public/sourcify.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + diff --git a/src/AddressTransactions.tsx b/src/AddressTransactions.tsx index e3a23a0..6baead0 100644 --- a/src/AddressTransactions.tsx +++ b/src/AddressTransactions.tsx @@ -13,7 +13,6 @@ import queryString from "query-string"; import Blockies from "react-blockies"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCircleNotch } from "@fortawesome/free-solid-svg-icons/faCircleNotch"; -import { faCheckCircle } from "@fortawesome/free-regular-svg-icons/faCheckCircle"; import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons/faQuestionCircle"; import StandardFrame from "./StandardFrame"; import StandardSubtitle from "./StandardSubtitle"; @@ -240,7 +239,13 @@ const AddressTransactions: React.FC = () => { ) : ( - + Sourcify logo )} @@ -300,10 +305,6 @@ const AddressTransactions: React.FC = () => { disabled={controller === undefined} /> - ) : ( diff --git a/src/Block.tsx b/src/Block.tsx index 7f9e552..b63e942 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -45,8 +45,8 @@ const Block: React.FC = () => { try { return block && toUtf8String(block.extraData); } catch (err) { - console.error("Error while converting block extra data to string"); - console.error(err); + console.info("Error while converting block extra data to string"); + console.info(err); } }, [block]); const burntFees = @@ -160,7 +160,7 @@ const Block: React.FC = () => { {extraStr} (Hex:{" "} - {block.extraData}) + {block.extraData}) diff --git a/src/search/TransactionItem.tsx b/src/search/TransactionItem.tsx index ffafc09..76e58e7 100644 --- a/src/search/TransactionItem.tsx +++ b/src/search/TransactionItem.tsx @@ -76,7 +76,7 @@ const TransactionItem: React.FC = ({ - + {tx.to !== null ? : } diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 716c529..4746cc5 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -72,10 +72,13 @@ const Details: React.FC = ({ } }, [txData]); - const fourBytes = rawInputTo4Bytes(txData.data); + const fourBytes = txData.to !== null ? rawInputTo4Bytes(txData.data) : "0x"; const fourBytesEntry = use4Bytes(fourBytes); const fourBytesTxDesc = useMemo(() => { - if (!txData || !fourBytesEntry?.signature) { + if (!fourBytesEntry) { + return fourBytesEntry; + } + if (!txData || !fourBytesEntry.signature) { return undefined; } const sig = fourBytesEntry?.signature; @@ -202,9 +205,11 @@ const Details: React.FC = ({ )} - - - + {txData.to && ( + + + + )} {txData.tokenTransfers.length > 0 && (
@@ -353,7 +358,7 @@ const Details: React.FC = ({ ) : resolvedTxDesc === undefined ? ( <>Waiting for data... ) : resolvedTxDesc === null ? ( - <>No decoded data + <>Can't decode data ) : ( = ({ txData, log, logDesc }) => ( -
-
- - {log.logIndex} - -
-
-
-
Address
-
-
- - - - +const LogEntry: React.FC = ({ txData, log, logDesc }) => { + const rawTopic0 = log.topics[0]; + const topic0 = useTopic0(rawTopic0); + + const topic0LogDesc = useMemo(() => { + if (!topic0) { + return topic0; + } + if (!topic0.signatures) { + return undefined; + } + + const sigs = topic0.signatures; + for (const sig of sigs) { + const logFragment = Fragment.fromString(`event ${sig}`); + const intf = new Interface([logFragment]); + try { + return intf.parseLog(log); + } catch (err) { + // Ignore on purpose; try to match other sigs + } + } + return undefined; + }, [topic0, log]); + + const resolvedLogDesc = logDesc ?? topic0LogDesc; + + return ( +
+
+ + {log.logIndex} + +
+
+
+
Address
+
+
+ + + + +
-
- - -
Parameters
-
- Decoded - Raw -
-
- - - {logDesc === undefined ? ( -
-
- Waiting for data... -
-
- ) : logDesc === null ? ( -
-
- No decoded data -
-
- ) : ( - <> -
-
- -
-
+ + +
Parameters
+
+ Decoded + Raw +
+
+ + + {resolvedLogDesc === undefined ? (
- + Waiting for data...
- - )} -
- - {log.topics.map((t, i) => ( -
-
{i === 0 && "Topics"}
-
- - {i} - - {t} + ) : resolvedLogDesc === null ? ( +
+
+ Can't decode data +
+
+ ) : ( + <> +
+
+ +
+
+
+
+ +
+
+ + )} + + + {log.topics.map((t, i) => ( +
+
{i === 0 && "Topics"}
+
+ + {i} + + {t} +
+
+ ))} +
+
Data
+
+