Flatten 4bytes signatures with param names

This commit is contained in:
Willian Mitsuda 2021-09-27 15:40:01 -03:00
parent 78d3c0e1b7
commit af95c04c9c
4 changed files with 10 additions and 37 deletions

View File

@ -14,10 +14,14 @@ WORKDIR /assets
COPY trustwallet/blockchains/ethereum/assets /assets/ COPY trustwallet/blockchains/ethereum/assets /assets/
RUN find . -name logo.png | parallel magick convert {} -filter Lanczos -resize 32x32 {} RUN find . -name logo.png | parallel magick convert {} -filter Lanczos -resize 32x32 {}
FROM alpine:3.14.0 AS fourbytesbuilder
WORKDIR /signatures
COPY 4bytes/signatures /signatures/
COPY 4bytes/with_parameter_names /signatures/
FROM nginx:1.21.1-alpine FROM nginx:1.21.1-alpine
RUN apk add jq RUN apk add jq
COPY 4bytes/signatures /usr/share/nginx/html/signatures/ COPY --from=fourbytesbuilder /signatures /usr/share/nginx/html/signatures/
COPY 4bytes/with_parameter_names /usr/share/nginx/html/with_parameter_names/
COPY --from=logobuilder /assets /usr/share/nginx/html/assets/ COPY --from=logobuilder /assets /usr/share/nginx/html/assets/
COPY nginx.conf /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /otterscan-build/build /usr/share/nginx/html/ COPY --from=builder /otterscan-build/build /usr/share/nginx/html/

View File

@ -43,40 +43,6 @@ server {
} }
} }
location /with_parameter_names {
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 { location /assets {
root /usr/share/nginx/html; root /usr/share/nginx/html;
expires 30d; expires 30d;

View File

@ -53,6 +53,7 @@
"eject": "react-scripts eject", "eject": "react-scripts eject",
"source-map-explorer": "source-map-explorer build/static/js/*.js", "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": "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-stop": "docker stop otterscan-assets", "assets-stop": "docker stop otterscan-assets",
"docker-build": "DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile .", "docker-build": "DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile .",
"docker-start": "docker run --rm -p 5000:80 --name otterscan -d otterscan", "docker-start": "docker run --rm -p 5000:80 --name otterscan -d otterscan",

View File

@ -59,7 +59,9 @@ export const use4Bytes = (
return; return;
} }
const sig = await res.text(); // Get only the first occurrence, for now ignore alternative param names
const sigs = await res.text();
const sig = sigs.split(";")[0];
const cut = sig.indexOf("("); const cut = sig.indexOf("(");
let method = sig.slice(0, cut); let method = sig.slice(0, cut);
method = method.charAt(0).toUpperCase() + method.slice(1); method = method.charAt(0).toUpperCase() + method.slice(1);