Skip to content

Commit

Permalink
Merge pull request #34 from map3xyz/identifier-fixes
Browse files Browse the repository at this point in the history
fixing issue in addIdentifierToAsset
  • Loading branch information
pellicceama authored Nov 4, 2022
2 parents e6dcc5b + 6f6b153 commit 6acbb31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/repo/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import test from "ava";
import { getDirPathForTokenlist } from ".";

test("getDirPathForTokenlist calculates the correct directory", async (t) => {
const network = 'ethereum';
const address = '0x';

t.deepEqual(getDirPathForTokenlist(network, address), `/networks/ethereum/assets/${network}-tokenlist/${address}`);
});
9 changes: 5 additions & 4 deletions src/repo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export function getGithubHostedFileUrl (dir: string, fileName: string) {
}

export function getDirPathForNetworkCode (network: string) {
return `/networks/${network}`;
return path.join('networks', network);
}

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

export async function addIdentifierToAsset(path: string, networkCode: string, address: string, identifierKey: string, identifierValue: string | number): Promise<{addedIdentifier: boolean}> {
export async function addIdentifierToAsset(dir: string, networkCode: string, address: string, identifierKey: string, identifierValue: string | number): Promise<{addedIdentifier: boolean}> {

const ALLOWED_IDENTIFIER_KEYS_FOR_ASSETS = [
'coinmarketcap'
Expand All @@ -84,9 +84,10 @@ export async function addIdentifierToAsset(path: string, networkCode: string, ad
throw new Error('Identifier key ' + identifierKey + ' is not allowed for assets');
}

const assetInfoFilePath = path + getDirPathForTokenlist(networkCode, address);
const assetInfoFilePath = path.join(dir, getDirPathForTokenlist(networkCode, address), 'info.json');

if(!fs.existsSync(assetInfoFilePath)) {
console.error('addIdentifierToAsset Cannot find asset info file for asset ' + address + ' in directory ' + dir);
return { addedIdentifier: false };
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/tcrs/kleros-tcr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function checkIfAssetInKlerosTCR(address: string): Promise<TcrCheck
}
}

// console.log('checkIfAssetInKlerosTCR Token', JSON.stringify(token));
return {
inTcr: token.status === 'Registered',
resolutionTxHash: token.requests[0].resolutionTx
Expand Down

0 comments on commit 6acbb31

Please sign in to comment.