Merge pull request #281 from ArtemKolodko/refactor_4bytes

Add env REACT_APP_VERIFICATION_SERVICE_URL; refactor 4bytes request
pull/282/head
Artem 1 year ago committed by GitHub
commit e6117c7728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .env.devnet
  2. 2
      .env.example
  3. 2
      .env.testnet
  4. 8
      src/api/explorerV1.ts
  5. 4
      src/config/index.ts
  6. 27
      src/pages/AddressPage/tabs/transactions/Transactions.tsx

@ -3,7 +3,7 @@ REACT_APP_RPC_URL_SHARD1=https://api.s1.ps.hmny.io/
REACT_APP_RPC_URL_SHARD2=
REACT_APP_RPC_URL_SHARD3=
REACT_APP_AVAILABLE_SHARDS=0,1
REACT_APP_EXPLORER_V1_API_URL=https://ctrver.t.hmny.io/
REACT_APP_VERIFICATION_SERVICE_URL=https://ctrver.t.hmny.io/
REACT_APP_INDEXER_IPFS_GATEWAY=https://ipfs.io/ipfs/
REACT_APP_PROD_ADDRESS=https://explorer-v2-api.ps.hmny.io
REACT_APP_CONTRACT_SHARD=0

@ -6,7 +6,7 @@ REACT_APP_RPC_URL_SHARD3=https://api.s3.t.hmny.io/
# supported shards, comma separated 0,1,2,3
REACT_APP_AVAILABLE_SHARDS=0,1,2,3
# api for contract verification
REACT_APP_EXPLORER_V1_API_URL=https://ctrver.t.hmny.io/
REACT_APP_VERIFICATION_SERVICE_URL=https://ctrver.t.hmny.io/
# IPFS gateway for tokens assets
REACT_APP_INDEXER_IPFS_GATEWAY=https://ipfs.io/ipfs/
# backend websocket API url

@ -3,7 +3,7 @@ REACT_APP_RPC_URL_SHARD1=https://api.s1.b.hmny.io/
REACT_APP_RPC_URL_SHARD2=
REACT_APP_RPC_URL_SHARD3=
REACT_APP_AVAILABLE_SHARDS=0,1
REACT_APP_EXPLORER_V1_API_URL=https://ctrver.t.hmny.io/
REACT_APP_VERIFICATION_SERVICE_URL=https://ctrver.b.hmny.io/
REACT_APP_INDEXER_IPFS_GATEWAY=https://ipfs.io/ipfs/
REACT_APP_PROD_ADDRESS=https://api.explorer.pops.one/
REACT_APP_CONTRACT_SHARD=0

@ -1,6 +1,6 @@
import { ShardID } from "src/types";
import { AbiItem } from "web3-utils";
import { getContractsByField } from "./client";
import { config } from '../config'
export interface IVerifyContractData {
contractAddress: string;
@ -65,7 +65,7 @@ export const verifyContractCode = async (data: IVerifyContractDataSendData) => {
}
const response = await fetch(
`${process.env.REACT_APP_EXPLORER_V1_API_URL}codeVerification`,
`${config.verificationServiceUrl}/codeVerification`,
{
method: "POST",
mode: "cors",
@ -86,7 +86,7 @@ export const verifyContractCode = async (data: IVerifyContractDataSendData) => {
}
else {
const response = await fetch(
`${process.env.REACT_APP_EXPLORER_V1_API_URL}codeVerification`,
`${config.verificationServiceUrl}/codeVerification`,
{
method: "POST",
mode: "cors",
@ -113,7 +113,7 @@ export const verifyContractCode = async (data: IVerifyContractDataSendData) => {
export const loadSourceCode = async (address: string, shard: ShardID): Promise<ISourceCode> => {
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",
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 oneCountryNFTContractAddress = process.env.REACT_APP_ONE_COUNTRY_NFT_CONTRACT_ADDRESS || ''
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 = {
availableShards,
@ -38,5 +39,6 @@ export const config = {
contractShardId,
oneCountryContractAddress,
oneCountryNFTContractAddress,
ipfsGateway
ipfsGateway,
verificationServiceUrl
}

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

Loading…
Cancel
Save