2021-07-17 18:00:08 +00:00
|
|
|
import { ethers } from "ethers";
|
|
|
|
import { TransactionData, Transfer } from "./types";
|
|
|
|
|
|
|
|
export const getTransactionTransfers = async (
|
|
|
|
provider: ethers.providers.JsonRpcProvider,
|
|
|
|
txData: TransactionData
|
|
|
|
) => {
|
2021-07-17 18:58:33 +00:00
|
|
|
const rawTransfers = await provider.send("ots_getTransactionTransfers", [
|
2021-07-17 18:00:08 +00:00
|
|
|
txData.transactionHash,
|
|
|
|
]);
|
|
|
|
|
|
|
|
const _transfers: Transfer[] = [];
|
2021-07-17 18:58:33 +00:00
|
|
|
for (const t of rawTransfers) {
|
|
|
|
_transfers.push({
|
|
|
|
from: ethers.utils.getAddress(t.from),
|
|
|
|
to: ethers.utils.getAddress(t.to),
|
|
|
|
value: t.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return _transfers;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getTransactionSelfDestructs = async (
|
|
|
|
provider: ethers.providers.JsonRpcProvider,
|
|
|
|
txData: TransactionData
|
|
|
|
) => {
|
|
|
|
const rawTransfers = await provider.send("ots_getTransactionSelfDestructs", [
|
|
|
|
txData.transactionHash,
|
|
|
|
]);
|
|
|
|
|
|
|
|
const _transfers: Transfer[] = [];
|
|
|
|
for (const t of rawTransfers) {
|
2021-07-17 18:00:08 +00:00
|
|
|
_transfers.push({
|
|
|
|
from: ethers.utils.getAddress(t.from),
|
|
|
|
to: ethers.utils.getAddress(t.to),
|
|
|
|
value: t.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return _transfers;
|
|
|
|
};
|