Add env REACT_APP_VERIFICATION_SERVICE_URL; refactor 4bytes request

pull/281/head
artemkolodko 1 year ago
parent da755b8875
commit 6bb5d52843
  1. 8
      src/api/explorerV1.ts
  2. 4
      src/config/index.ts
  3. 27
      src/pages/AddressPage/tabs/transactions/Transactions.tsx

@ -1,6 +1,6 @@
import { ShardID } from "src/types"; import { ShardID } from "src/types";
import { AbiItem } from "web3-utils"; import { AbiItem } from "web3-utils";
import { getContractsByField } from "./client"; import { config } from '../config'
export interface IVerifyContractData { export interface IVerifyContractData {
contractAddress: string; contractAddress: string;
@ -65,7 +65,7 @@ export const verifyContractCode = async (data: IVerifyContractDataSendData) => {
} }
const response = await fetch( const response = await fetch(
`${process.env.REACT_APP_EXPLORER_V1_API_URL}codeVerification`, `${config.verificationServiceUrl}/codeVerification`,
{ {
method: "POST", method: "POST",
mode: "cors", mode: "cors",
@ -86,7 +86,7 @@ export const verifyContractCode = async (data: IVerifyContractDataSendData) => {
} }
else { else {
const response = await fetch( const response = await fetch(
`${process.env.REACT_APP_EXPLORER_V1_API_URL}codeVerification`, `${config.verificationServiceUrl}/codeVerification`,
{ {
method: "POST", method: "POST",
mode: "cors", mode: "cors",
@ -113,7 +113,7 @@ export const verifyContractCode = async (data: IVerifyContractDataSendData) => {
export const loadSourceCode = async (address: string, shard: ShardID): Promise<ISourceCode> => { export const loadSourceCode = async (address: string, shard: ShardID): Promise<ISourceCode> => {
const response = await fetch( const response = await fetch(
`${process.env.REACT_APP_EXPLORER_V1_API_URL}fetchContractCode?contractAddress=${address}&shard=${shard}`, `${config.verificationServiceUrl}/fetchContractCode?contractAddress=${address}&shard=${shard}`,
{ {
mode: "cors", mode: "cors",
cache: "no-cache", cache: "no-cache",

@ -31,6 +31,7 @@ const contractShardId = +(process.env.REACT_APP_CONTRACT_SHARD || '0') as ShardI
const oneCountryContractAddress = process.env.REACT_APP_ONE_COUNTRY_CONTRACT_ADDRESS || '' const oneCountryContractAddress = process.env.REACT_APP_ONE_COUNTRY_CONTRACT_ADDRESS || ''
const oneCountryNFTContractAddress = process.env.REACT_APP_ONE_COUNTRY_NFT_CONTRACT_ADDRESS || '' const oneCountryNFTContractAddress = process.env.REACT_APP_ONE_COUNTRY_NFT_CONTRACT_ADDRESS || ''
const ipfsGateway = process.env.REACT_APP_INDEXER_IPFS_GATEWAY || '' const ipfsGateway = process.env.REACT_APP_INDEXER_IPFS_GATEWAY || ''
const verificationServiceUrl = process.env.REACT_APP_VERIFICATION_SERVICE_URL || 'https://ctrver.t.hmny.io'
export const config = { export const config = {
availableShards, availableShards,
@ -38,5 +39,6 @@ export const config = {
contractShardId, contractShardId,
oneCountryContractAddress, oneCountryContractAddress,
oneCountryNFTContractAddress, oneCountryNFTContractAddress,
ipfsGateway ipfsGateway,
verificationServiceUrl
} }

@ -130,18 +130,27 @@ export function Transactions(props: {
// for transactions we display call method if any // for transactions we display call method if any
if (props.type === "transaction") { if (props.type === "transaction") {
const methodSignatures = await Promise.all( const txInputsMap: Record<string, string> = {}
txs.map((tx: any) => { txs.forEach((tx) => {
return tx.input && tx.input.length > 10 if(tx.input && tx.input.length > 10) {
? getByteCodeSignatureByHash([tx.input.slice(0, 10)]) txInputsMap[tx.input.slice(0, 10)] = ''
: Promise.resolve([]); }
})
await Promise.all(
Object.keys(txInputsMap).map(async (txInput: string) => {
txInputsMap[txInput] = await getByteCodeSignatureByHash([txInput]);
}) })
); );
txs = txs.map((l, i) => ({ txs = txs.map((tx, i) => {
...l, return {
signatures: methodSignatures[i], ...tx,
})); signatures: tx.input
? txInputsMap[tx.input.slice(0, 10)] || []
: [],
}
});
} }
txs = txs.map((tx: any) => { txs = txs.map((tx: any) => {

Loading…
Cancel
Save