2021-07-17 18:00:08 +00:00
|
|
|
import { ethers } from "ethers";
|
2021-07-21 19:06:51 +00:00
|
|
|
import { TransactionData, 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,
|
|
|
|
txData: TransactionData
|
|
|
|
) => {
|
2021-07-21 19:06:51 +00:00
|
|
|
const rawTransfers = await provider.send("ots_getInternalOperations", [
|
2021-07-17 18:00:08 +00:00
|
|
|
txData.transactionHash,
|
|
|
|
]);
|
|
|
|
|
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;
|
|
|
|
};
|