Use first iteration of ots_getBlockTransactions
This commit is contained in:
parent
795d054a38
commit
e03e27c71b
|
@ -1,5 +1,6 @@
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { ethers, BigNumber } from "ethers";
|
import { ethers, BigNumber } from "ethers";
|
||||||
|
import { BlockWithTransactions } from "@ethersproject/abstract-provider";
|
||||||
import { getInternalOperations } from "./nodeFunctions";
|
import { getInternalOperations } from "./nodeFunctions";
|
||||||
import {
|
import {
|
||||||
TokenMetas,
|
TokenMetas,
|
||||||
|
@ -75,12 +76,15 @@ export const useBlockTransactions = (
|
||||||
}
|
}
|
||||||
|
|
||||||
const readBlock = async () => {
|
const readBlock = async () => {
|
||||||
const [_block, _receipts] = await Promise.all([
|
const result = await provider.send("ots_getBlockTransactions", [
|
||||||
provider.getBlockWithTransactions(blockNumber),
|
blockNumber,
|
||||||
provider.send("eth_getBlockReceipts", [blockNumber]),
|
|
||||||
]);
|
]);
|
||||||
|
const _block = provider.formatter.blockWithTransactions(
|
||||||
|
result.fullblock
|
||||||
|
) as unknown as BlockWithTransactions;
|
||||||
|
const _receipts = result.receipts;
|
||||||
|
|
||||||
const responses = _block.transactions
|
const rawTxs = _block.transactions
|
||||||
.map(
|
.map(
|
||||||
(t, i): ProcessedTransaction => ({
|
(t, i): ProcessedTransaction => ({
|
||||||
blockNumber: blockNumber,
|
blockNumber: blockNumber,
|
||||||
|
@ -109,10 +113,10 @@ export const useBlockTransactions = (
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.reverse();
|
.reverse();
|
||||||
setTxs(responses);
|
setTxs(rawTxs);
|
||||||
|
|
||||||
const checkTouchMinerAddr = await Promise.all(
|
const checkTouchMinerAddr = await Promise.all(
|
||||||
responses.map(async (res) => {
|
rawTxs.map(async (res) => {
|
||||||
const ops = await getInternalOperations(provider, res.hash);
|
const ops = await getInternalOperations(provider, res.hash);
|
||||||
return (
|
return (
|
||||||
ops.findIndex(
|
ops.findIndex(
|
||||||
|
@ -124,13 +128,13 @@ export const useBlockTransactions = (
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const processedResponses = responses.map(
|
const processedTxs = rawTxs.map(
|
||||||
(r, i): ProcessedTransaction => ({
|
(r, i): ProcessedTransaction => ({
|
||||||
...r,
|
...r,
|
||||||
internalMinerInteraction: checkTouchMinerAddr[i],
|
internalMinerInteraction: checkTouchMinerAddr[i],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
setTxs(processedResponses);
|
setTxs(processedTxs);
|
||||||
};
|
};
|
||||||
readBlock();
|
readBlock();
|
||||||
}, [provider, blockNumber]);
|
}, [provider, blockNumber]);
|
||||||
|
|
Loading…
Reference in New Issue