Skip to content

Commit

Permalink
Merge pull request #22 from map3xyz/tsv
Browse files Browse the repository at this point in the history
Tsv
  • Loading branch information
pellicceama authored Aug 12, 2022
2 parents e0c228e + 639e38e commit 17e363e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@map3xyz/assets-helper",
"version": "1.0.118",
"version": "1.0.119",
"description": "A library for maintaining the assets repo.",
"author": "pellicceama",
"keywords": [
Expand Down
12 changes: 6 additions & 6 deletions src/trustwallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ function getLinks(input: any) {
return links;
}

export async function getTwaTokenInfo(t: Asset, chainId: number): Promise<Asset> {
export async function getTwaTokenInfo(t: Asset, chainId: number, twaRepoLoc: string = DEFAULT_TWA_DISK_LOCATION): Promise<Asset> {

try {

const network = await getNetworkForChainId(chainId);
await cloneOrPullRepoAndUpdateSubmodules(TWA_REPO_CLONE_URL, DEFAULT_TWA_DISK_LOCATION, false, "master");
await cloneOrPullRepoAndUpdateSubmodules(TWA_REPO_CLONE_URL, twaRepoLoc, false, "master");

// note: if trustwallet names the network different to our networkId,
// even if they have the same chainId we may encounter issues
// as we may not find the infoFilePath.
// TODO; Handle this case better
const infoFilePath = path.join(DEFAULT_TWA_DISK_LOCATION, 'blockchains', network.networkId, 'assets', t.address, 'info.json');
const infoFilePath = path.join(twaRepoLoc, 'blockchains', network.networkId, 'assets', t.address, 'info.json');
const logoHttpPath = `${TWA_USER_CONTENT_BASE}/blockchains/${network.networkId}/assets/${t.address}/logo.png`;

if(!fs.existsSync(infoFilePath)) {
Expand Down Expand Up @@ -85,11 +85,11 @@ export async function getTwaTokenInfo(t: Asset, chainId: number): Promise<Asset>
}
}

export async function getTwaNetworkInfo(twaNetworkName: string): Promise<Network> {
const infoFilePath = path.join(DEFAULT_TWA_DISK_LOCATION, 'blockchains', twaNetworkName, 'info', 'info.json');
export async function getTwaNetworkInfo(twaNetworkName: string, twaRepoLoc: string = DEFAULT_TWA_DISK_LOCATION): Promise<Network> {
const infoFilePath = path.join(twaRepoLoc, 'blockchains', twaNetworkName, 'info', 'info.json');
const logoHttpPath = `${TWA_USER_CONTENT_BASE}/blockchains/${twaNetworkName}/info/logo.png`;

await cloneOrPullRepoAndUpdateSubmodules(TWA_REPO_CLONE_URL, DEFAULT_TWA_DISK_LOCATION, false, "master");
await cloneOrPullRepoAndUpdateSubmodules(TWA_REPO_CLONE_URL, twaRepoLoc, false, "master");

const i = JSON.parse(fs.readFileSync(infoFilePath, 'utf-8'));

Expand Down

0 comments on commit 17e363e

Please sign in to comment.