Simplify search
This commit is contained in:
parent
32ea63a3d0
commit
1dfafb2966
|
@ -5,13 +5,10 @@ import queryString from "query-string";
|
||||||
import StandardFrame from "./StandardFrame";
|
import StandardFrame from "./StandardFrame";
|
||||||
import BlockTransactionHeader from "./block/BlockTransactionHeader";
|
import BlockTransactionHeader from "./block/BlockTransactionHeader";
|
||||||
import BlockTransactionResults from "./block/BlockTransactionResults";
|
import BlockTransactionResults from "./block/BlockTransactionResults";
|
||||||
import {
|
import { OperationType, ProcessedTransaction } from "./types";
|
||||||
InternalOperation,
|
|
||||||
OperationType,
|
|
||||||
ProcessedTransaction,
|
|
||||||
} from "./types";
|
|
||||||
import { PAGE_SIZE } from "./params";
|
import { PAGE_SIZE } from "./params";
|
||||||
import { RuntimeContext } from "./useRuntime";
|
import { RuntimeContext } from "./useRuntime";
|
||||||
|
import { getInternalOperations } from "./nodeFunctions";
|
||||||
|
|
||||||
type BlockParams = {
|
type BlockParams = {
|
||||||
blockNumber: string;
|
blockNumber: string;
|
||||||
|
@ -82,29 +79,21 @@ const BlockTransactions: React.FC = () => {
|
||||||
.reverse();
|
.reverse();
|
||||||
setTxs(responses);
|
setTxs(responses);
|
||||||
|
|
||||||
const internalChecks = await Promise.all(
|
const checkTouchMinerAddr = await Promise.all(
|
||||||
responses.map(async (res) => {
|
responses.map(async (res) => {
|
||||||
const r: InternalOperation[] = await provider.send(
|
const ops = await getInternalOperations(provider, res.hash);
|
||||||
"ots_getInternalOperations",
|
return (
|
||||||
[res.hash]
|
ops.findIndex(
|
||||||
|
(op) =>
|
||||||
|
op.type === OperationType.TRANSFER &&
|
||||||
|
res.miner !== undefined &&
|
||||||
|
res.miner === ethers.utils.getAddress(op.to)
|
||||||
|
) !== -1
|
||||||
);
|
);
|
||||||
for (const op of r) {
|
|
||||||
if (op.type !== OperationType.TRANSFER) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
res.miner &&
|
|
||||||
(res.miner === ethers.utils.getAddress(op.from) ||
|
|
||||||
res.miner === ethers.utils.getAddress(op.to))
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const processedResponses = responses.map((r, i): ProcessedTransaction => {
|
const processedResponses = responses.map((r, i): ProcessedTransaction => {
|
||||||
return { ...r, internalMinerInteraction: internalChecks[i] };
|
return { ...r, internalMinerInteraction: checkTouchMinerAddr[i] };
|
||||||
});
|
});
|
||||||
setTxs(processedResponses);
|
setTxs(processedResponses);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue