otterscan/src/nodeFunctions.ts

23 lines
553 B
TypeScript
Raw Normal View History

2021-07-17 18:00:08 +00:00
import { ethers } from "ethers";
2021-08-02 02:10:32 +00:00
import { InternalOperation } from "./types";
2021-07-17 18:00:08 +00:00
2021-07-21 19:06:51 +00:00
export const getInternalOperations = async (
2021-07-17 18:00:08 +00:00
provider: ethers.providers.JsonRpcProvider,
2021-08-02 02:10:32 +00:00
txHash: string
2021-07-17 18:00:08 +00:00
) => {
2021-07-21 19:06:51 +00:00
const rawTransfers = await provider.send("ots_getInternalOperations", [
2021-08-02 02:10:32 +00:00
txHash,
2021-07-17 18:00:08 +00:00
]);
2021-07-21 19:06:51 +00:00
const _transfers: InternalOperation[] = [];
2021-07-17 18:58:33 +00:00
for (const t of rawTransfers) {
_transfers.push({
2021-07-19 23:49:54 +00:00
type: t.type,
2021-07-17 18:00:08 +00:00
from: ethers.utils.getAddress(t.from),
to: ethers.utils.getAddress(t.to),
value: t.value,
});
}
return _transfers;
};