Skip to content

Commit

Permalink
Make address linkable to marketplace profile url
Browse files Browse the repository at this point in the history
  • Loading branch information
kryptoj committed Oct 11, 2022
1 parent 0d86280 commit 0776e73
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lib/discord/notifyDiscordSale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Discord, {
MessageEmbed,
TextChannel,
} from "discord.js";
import { NFTSale, SaleMethod } from "lib/marketplaces";
import { Marketplace, NFTSale, SaleMethod } from "lib/marketplaces";
import truncateForAddress from "lib/truncateForAddress";
import logger from "lib/logger";
import { fetchDiscordChannel } from "./index";
Expand Down Expand Up @@ -80,12 +80,14 @@ export default async function notifyDiscordSale(
},
{
name: "Buyer",
value: truncateForAddress(nftSale.buyer),
value: formatAddress(marketplace, nftSale.buyer),
inline: true,
},
{
name: "Seller",
value: nftSale.seller ? truncateForAddress(nftSale.seller) : "unknown",
value: nftSale.seller
? formatAddress(marketplace, nftSale.seller)
: "unknown",
inline: true,
},
],
Expand Down Expand Up @@ -113,3 +115,11 @@ export default async function notifyDiscordSale(
status.totalNotified++;
}
}

function formatAddress(marketplace: Marketplace, address: string): string {
if (!address) {
return "";
}

return `[${truncateForAddress(address)}](${marketplace.profileURL(address)})`;
}
2 changes: 2 additions & 0 deletions src/lib/marketplaces/alphaArt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const alphaArt: Marketplace = {
iconURL: "https://alpha.art/favicon.ico",
programId: ["HZaWndaNWHFDd9Dhk5pqUUtsmoBCqzb1MLu3NAh1VX6B"],
itemURL: (token: String) => `https://alpha.art/t/${token}`,
profileURL: (address: String) =>
`https://explorer.solana.com/address/${address}`,
parseNFTSale(web3Conn, txResp): Promise<NFTSale | null> {
return parseNFTSaleOnTx(web3Conn, txResp, this, 1);
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/marketplaces/digitalEyes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const digitalEyes: Marketplace = {
programId: ["A7p8451ktDCHq5yYaHczeLMYsjRsAkzc3hCXcSrwYHU7"],
iconURL: "https://digitaleyes.market/apple-touch-icon.png",
itemURL: (token: String) => `https://digitaleyes.market/item/${token}`,
profileURL: (address: String) =>
`https://explorer.solana.com/address/${address}`,
parseNFTSale(web3Conn, txResp): Promise<NFTSale | null> {
return parseNFTSaleOnTx(web3Conn, txResp, this, 1);
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/marketplaces/exchangeArt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const exchangeArt: Marketplace = {
programId: ["AmK5g2XcyptVLCFESBCJqoSfwV3znGoVYQnqEnaAZKWn"],
iconURL: "https://cdn.exchange.art/static/apple-meta-logo.png",
itemURL: (token: String) => `https://exchange.art/single/${token}`,
profileURL: (address: String) =>
`https://explorer.solana.com/address/${address}`,
parseNFTSale(web3Conn, txResp): Promise<NFTSale | null> {
return parseNFTSaleOnTx(web3Conn, txResp, this);
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/marketplaces/magicEden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const magicEden: Marketplace = {
],
iconURL: "https://www.magiceden.io/img/favicon.png",
itemURL: (token: String) => `https://magiceden.io/item-details/${token}`,
profileURL: (address: String) => `https://magiceden.io/u/${address}`,
parseNFTSale(web3Conn, txResp): Promise<NFTSale | null> {
return parseNFTSaleOnTx(web3Conn, txResp, this);
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/marketplaces/openSea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const openSea: Marketplace = {
iconURL:
"https://storage.googleapis.com/opensea-static/Logomark/Logomark-Blue.png",
itemURL: (token: String) => `https://opensea.io/assets/solana/${token}`,
profileURL: (address: String) => `https://opensea.io/${address}`,
parseNFTSale(web3Conn, txResp): Promise<NFTSale | null> {
return parseNFTSaleOnTx(web3Conn, txResp, this);
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/marketplaces/solanart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const solanart: Marketplace = {
programId: ["CJsLwbP1iu5DuUikHEJnLfANgKy6stB2uFgvBBHoyxwz"],
iconURL: "https://solanart.io/logo192.png",
itemURL: (token: String) => `https://solanart.io/nft/${token}`,
profileURL: (address: String) =>
`https://explorer.solana.com/address/${address}`,
parseNFTSale(web3Conn, txResp): Promise<NFTSale | null> {
return parseNFTSaleOnTx(web3Conn, txResp, this);
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/marketplaces/solsea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const solsea: Marketplace = {
programId: ["617jbWo616ggkDxvW1Le8pV38XLbVSyWY8ae6QUmGBAU"],
iconURL: "https://solsea.io/logo_solo.svg",
itemURL: (token: String) => `https://solsea.io/nft/${token}`,
profileURL: (address: String) =>
`https://explorer.solana.com/address/${address}`,
parseNFTSale(web3Conn, txResp): Promise<NFTSale | null> {
return parseNFTSaleOnTx(web3Conn, txResp, this, 0);
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/marketplaces/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Marketplace {
programId: string[];
iconURL: string;
itemURL: (token: String) => string;
profileURL: (address: String) => string;
parseNFTSale: (
web3Conn: Connection,
tx: ParsedConfirmedTransaction
Expand Down

0 comments on commit 0776e73

Please sign in to comment.