Skip to content

Commit

Permalink
Token names are being shown
Browse files Browse the repository at this point in the history
  • Loading branch information
ac10n committed Jan 12, 2023
1 parent c453e5a commit 540d0ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion taqueria-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@
},
"scripts": {
"vscode:prepublish": "npm run compile:base -- --minify",
"compile:base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
"compile:base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --external:pg-native --format=cjs --platform=node",
"compile": "npx tsc -noEmit && npm run compile:base -- --sourcemap",
"compile:watch": "npm run compile:base -- --sourcemap --watch",
"compile:test": "tsc -p tsconfig.test.json",
Expand Down
2 changes: 1 addition & 1 deletion taqueria-vscode-extension/src/lib/gui/DataModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type TokenInfo_Dipdup = {
id: bigint;
token_id: bigint;
link: string | undefined | null;
metadata: string | undefined | null;
metadata: TokenMetadata | undefined | null;
image_processed: boolean | undefined | null;
};

Expand Down
14 changes: 10 additions & 4 deletions taqueria-vscode-extension/src/lib/gui/SandboxesDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,15 @@ export class SandboxesDataProvider extends TaqueriaDataProviderBase
}

async getTokens(element: SmartContractChildrenTreeItem): Promise<TokenTreeItem[]> {
const data = await this.getTokensFromTzKt(element);
return data.map(item => new TokenTreeItem(item.tokenId, item.metadata?.name));
const [dataFromTzKt, dataFromDipdup] = await Promise.all([
this.getTokensFromTzKt(element),
this.getTokensFromDipdup(element),
]);
const data = dataFromTzKt.map(tzKtItem => ({
tzKtItem,
dipDupItem: dataFromDipdup.find(dipDupItem => dipDupItem.token_id.toString() === tzKtItem.tokenId),
}));
return data.map(item => new TokenTreeItem(item.tzKtItem.tokenId, item.dipDupItem?.metadata?.name));
}

private async getTokensFromTzKt(element: SmartContractChildrenTreeItem): Promise<TokenInfo_TzKt[]> {
Expand All @@ -428,12 +435,11 @@ export class SandboxesDataProvider extends TaqueriaDataProviderBase
const pool = this.pools.getPool(connectionString);
const contractAddress = element.parent.address;
const tokens = await pool.query(`select * from token_metadata where contract='${contractAddress}'`);
this.helper.logHelper.showOutput(JSON.stringify(tokens.rows));
return tokens.rows.map(row => ({
id: row.id,
token_id: row.token_id,
link: row.link,
metadata: JSON.parse(row.metadata),
metadata: row.metadata,
image_processed: row.image_processed,
}));
}
Expand Down

0 comments on commit 540d0ee

Please sign in to comment.