Skip to content

Commit

Permalink
improving add mapping defensiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
pellicceama committed Nov 3, 2022
1 parent 291e32b commit aeee61d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/repo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export function addAssetMap(map: AssetMap, repoPath: string = DEFAULT_REPO_DISK_
const assetMaps = readAndParseJson(assetMapInfoFile)
.map(map => new AssetMap(map));

assetMaps.push(map);

fs.writeFileSync(assetMapInfoFile, JSON.stringify(assetMaps, null, 2));
const existingMap = assetMaps.find(_map => _map.fromAddress === map.fromAddress && _map.fromNetwork === map.fromNetwork && _map.toAddress === map.toAddress && _map.toNetwork === map.toNetwork);
if(!existingMap) {
assetMaps.push(map);
fs.writeFileSync(assetMapInfoFile, JSON.stringify(assetMaps, null, 2));
}
}

0 comments on commit aeee61d

Please sign in to comment.