2023-01-03 22:19:13 -05:00
|
|
|
import { Epml } from '../../epml.js';
|
2023-01-04 13:46:19 -05:00
|
|
|
import { cropAddress } from './cropAddress.js';
|
2023-01-03 22:19:13 -05:00
|
|
|
|
|
|
|
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
|
|
|
|
|
|
|
|
export const getUserNameFromAddress = async (address) => {
|
|
|
|
try {
|
|
|
|
const getNames = await parentEpml.request("apiCall", {
|
|
|
|
type: "api",
|
|
|
|
url: `/names/address/${address}`,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (Array.isArray(getNames) && getNames.length > 0 ) {
|
|
|
|
return getNames[0].name;
|
|
|
|
} else {
|
2023-01-06 14:13:13 -05:00
|
|
|
return address;
|
2023-01-03 22:19:13 -05:00
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
}
|