Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ERC721 Changes with the floor price #1

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/Tenderly/tenderly-metamask-snap-simulate-asset-changes.git"
},
"source": {
"shasum": "L6hmfJq6J10dJVtzOLfv47Goz5j6SUfo2FvXJToowyE=",
"shasum": "9Qy94W81xSy0NVW/77DwofrhrQtavXsgyZnvgA6Icbs=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
29 changes: 20 additions & 9 deletions packages/snap/src/tenderly/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,36 +123,47 @@ function formatAssetChanges(data: any): Component[] {

assetChanges.forEach((assetChange: any) => {
if (assetChange.token_info.standard === 'ERC20') {
erc20Outputs.push(text(`**${assetChange.token_info.name}**`));
erc20Outputs.push(text(`Change Type: ${assetChange.type}`));
erc20Outputs.push(
text(
`Amount: ${assetChange.amount} **($${Number(
assetChange.dollar_value,
).toFixed(2)})**`,
`**${
assetChange.token_info.name
} (${assetChange.token_info.symbol?.toUpperCase()})**`,
),
);
erc20Outputs.push(text(`Change Type: ${assetChange.type}`));
erc20Outputs.push(
text(`Price: $${Number(assetChange.dollar_value).toFixed(4)}`),
);
erc20Outputs.push(text(`Amount: ${assetChange.amount}`));
erc20Outputs.push(divider());
} else if (assetChange.token_info.standard === 'ERC721') {
// Don't show dollar value since it's not supported (always $0)
erc721Outputs.push(text(`**${assetChange.token_info.name}**`));
erc721Outputs.push(
text(
`**${
assetChange.token_info.name
} (${assetChange.token_info.symbol?.toUpperCase()})**`,
),
);
erc721Outputs.push(text(`Change Type: ${assetChange.type}`));
erc721Outputs.push(
text(`Floor Price: $${Number(assetChange.dollar_value).toFixed(4)}`),
);
erc721Outputs.push(text(`Amount: ${assetChange.amount}`));
erc721Outputs.push(divider());
} else {
otherOutputs.push(
text(
`**${assetChange.token_info.name}** ($${Number(
assetChange.token_info.dollar_value,
).toFixed(2)})`,
).toFixed(4)})`,
),
);
otherOutputs.push(text(`Change Type: ${assetChange.type}`));
otherOutputs.push(
text(
`Amount: ${assetChange.amount} **($${Number(
assetChange.dollar_value,
).toFixed(2)})**`,
).toFixed(4)})**`,
),
);
otherOutputs.push(divider());
Expand Down