Skip to content

Commit

Permalink
Show token metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ac10n committed Jan 11, 2023
1 parent 26f91ce commit 4974d83
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
16 changes: 16 additions & 0 deletions taqueria-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@
"title": "Invoke Entrypoint",
"shortTitle": "invoke",
"icon": "$(call-outgoing)"
},
{
"command": "taqueria.show_token_metadata",
"category": "Taqueria",
"title": "Show Token Metadata",
"shortTitle": "show token metadata",
"icon": "$(list-unordered)"
}
],
"menus": {
Expand Down Expand Up @@ -482,6 +489,10 @@
{
"command": "taqueria.originate",
"when": "false"
},
{
"command": "taqueria.show_token_metadata",
"when": "false"
}
],
"explorer/context": [
Expand Down Expand Up @@ -631,6 +642,11 @@
"command": "taqueria.show_operation_details",
"when": "view == taqueria-sandboxes && viewItem == operation",
"group": "inline"
},
{
"command": "taqueria.show_token_metadata",
"when": "view == taqueria-sandboxes && viewItem == token",
"group": "inline"
}
],
"view/title": [
Expand Down
3 changes: 3 additions & 0 deletions taqueria-vscode-extension/src/lib/gui/SandboxTreeItemTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import { SandboxState } from './CachedSandboxState';
import { TokenMetadata } from './DataModels';

export class SandboxTreeItemBase extends vscode.TreeItem {
constructor(
Expand Down Expand Up @@ -146,7 +147,9 @@ export class TokenTreeItem extends SandboxTreeItemBase {
constructor(
public readonly tokenId: string,
public readonly name: string | undefined,
public readonly metadata: TokenMetadata | undefined,
) {
super(name || tokenId.toString(), 'token', vscode.TreeItemCollapsibleState.None);
this.contextValue = 'token';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ export class SandboxesDataProvider extends TaqueriaDataProviderBase
tzKtItem,
dipDupItem: dataFromDipdup.find(dipDupItem => dipDupItem.token_id.toString() === tzKtItem.tokenId),
}));
return data.map(item => new TokenTreeItem(item.tzKtItem.tokenId, item.dipDupItem?.metadata?.name));
return data.map(item =>
new TokenTreeItem(item.tzKtItem.tokenId, item.dipDupItem?.metadata?.name, item.dipDupItem?.metadata ?? undefined)
);
}

private async getTokensFromTzKt(element: SmartContractChildrenTreeItem): Promise<TokenInfo_TzKt[]> {
Expand Down
9 changes: 9 additions & 0 deletions taqueria-vscode-extension/src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
SandboxTreeItem,
SandboxTreeItemBase,
SmartContractEntrypointTreeItem,
TokenTreeItem,
} from './gui/SandboxTreeItemTypes';
import { ScaffoldsDataProvider, ScaffoldTreeItem } from './gui/ScaffoldsDataProvider';
import { SystemCheckDataProvider, SystemCheckTreeItem } from './gui/SystemCheckDataProvider';
Expand Down Expand Up @@ -241,6 +242,7 @@ export class VsCodeHelper {
this.exposeRefreshSandBoxDataCommand();
this.exposeShowEntrypointParametersCommand();
this.exposeShowOperationDetailsCommand();
this.exposeShowTokenMetadataCommand();
this.exposeInvokeEntrypointCommand();

await this.registerDataProviders();
Expand Down Expand Up @@ -1729,6 +1731,13 @@ export class VsCodeHelper {
});
}

exposeShowTokenMetadataCommand() {
this.registerCommand('show_token_metadata', async (item: TokenTreeItem) => {
const metadata = item.metadata;
this.logHelper.showOutput(JSON.stringify(metadata, null, 2));
});
}

exposeInvokeEntrypointCommand() {
this.registerCommand(
'invoke_entrypoint',
Expand Down

0 comments on commit 4974d83

Please sign in to comment.