2021-08-08 22:49:45 +00:00
|
|
|
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 (
|
2021-08-08 22:49:45 +00:00
|
|
|
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,
|
2021-08-08 22:49:45 +00:00
|
|
|
from: getAddress(t.from),
|
|
|
|
to: getAddress(t.to),
|
2021-07-17 18:00:08 +00:00
|
|
|
value: t.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return _transfers;
|
|
|
|
};
|