Skip to content

Commit

Permalink
making helper maps find function accept an optional address
Browse files Browse the repository at this point in the history
  • Loading branch information
pellicceama committed Nov 12, 2022
1 parent c122b89 commit 0238493
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/repo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ export function getDirPathForNetworkCode (network: string) {
}

export function getDirPathForTokenlist (network: string, address?: string) {
return path.join(getDirPathForNetworkCode(network),'assets',`${network}-tokenlist`, (address ? `/${address}` : ''));
let addr = address;

if(address) {
addr = formatAddress(addr);
}
return path.join(getDirPathForNetworkCode(network),'assets',`${network}-tokenlist`, (addr ? `/${addr}` : ''));
}

export async function addIdentifierToAsset(dir: string, networkCode: string, address: string, identifierKey: string, identifierValue: string | number): Promise<{addedIdentifier: boolean}> {
Expand Down Expand Up @@ -106,10 +111,8 @@ export async function addIdentifierToAsset(dir: string, networkCode: string, add
}
}

export function getAssetMaps(networkCode: string, address: string, repoPath: string = DEFAULT_REPO_DISK_LOCATION): AssetMap[] {
const formattedAddress = formatAddress(address);

const assetMapInfoFile = path.join(repoPath, getDirPathForTokenlist(networkCode, formattedAddress), 'maps.json');
export function getAssetMaps(networkCode: string, address?: string, repoPath: string = DEFAULT_REPO_DISK_LOCATION): AssetMap[] {
const assetMapInfoFile = path.join(repoPath, getDirPathForTokenlist(networkCode, address), 'maps.json');

if(!fs.existsSync(assetMapInfoFile)) {
return [];
Expand Down

0 comments on commit 0238493

Please sign in to comment.