otterscan/src/nodeFunctions.ts

24 lines
590 B
TypeScript
Raw Normal View History

import { JsonRpcProvider } from "@ethersproject/providers";
import { getAddress } from "@ethersproject/address";
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 (
provider: 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,
from: getAddress(t.from),
to: getAddress(t.to),
2021-07-17 18:00:08 +00:00
value: t.value,
});
}
return _transfers;
};