mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-24 12:09:06 +00:00
a7ec3d8da8
* Add license & copyright declarations for add-watcher. * Add copyright declarations for cache. * Add copyright declarations for erc20-watcher. * Add copyright declarations for ipld-eth-client. * Add copyright declarations for tracing-client. * Add copyright declarations for uni-watcher. * Add copyright declarations for solidity-mapper. * Add copyright declarations for uni-info-watcher. * Add copyright declarations for util. * Add copyright declarations for lighthouse-watcher. * Change license identifier in .sol files. Co-authored-by: prathamesh0 <prathamesh.musale0@gmail.com>
34 lines
660 B
TypeScript
34 lines
660 B
TypeScript
//
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
//
|
|
|
|
import _ from 'lodash';
|
|
import { ethers } from 'ethers';
|
|
|
|
export const addressesInTrace = (obj: any): any => {
|
|
return _.uniq(_.compact(_.flattenDeep(addressesIn(obj))))
|
|
.sort()
|
|
.map(address => ethers.utils.getAddress(<string>address));
|
|
};
|
|
|
|
const addressesIn = (obj: any): any => {
|
|
const addresses: any = [];
|
|
|
|
if (obj) {
|
|
addresses.push(obj.from);
|
|
addresses.push(obj.to);
|
|
|
|
if (obj.addresses) {
|
|
addresses.push(_.keys(obj.addresses));
|
|
}
|
|
|
|
if (obj.calls) {
|
|
obj.calls.forEach((call: any) => {
|
|
addresses.push(addressesIn(call));
|
|
});
|
|
}
|
|
}
|
|
|
|
return addresses;
|
|
};
|