-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #400 from enkryptcom/develop
Release: v1.33.0
- Loading branch information
Showing
89 changed files
with
2,329 additions
and
917 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
packages/extension/src/libs/nft-handlers/simplehash-ordinals.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { NFTCollection, NFTItem, NFTType } from "@/types/nft"; | ||
import cacheFetch from "../cache-fetch"; | ||
import { NetworkNames } from "@enkryptcom/types"; | ||
import { SHOrdinalsNFTType, SHOrdinalsResponse } from "./types/simplehash"; | ||
import { BaseNetwork } from "@/types/base-network"; | ||
const SH_ENDPOINT = "https://partners.mewapi.io/nfts/"; | ||
const CACHE_TTL = 1 * 1000; | ||
export default async ( | ||
network: BaseNetwork, | ||
address: string | ||
): Promise<NFTCollection[]> => { | ||
const supportedNetworks = { | ||
[NetworkNames.Bitcoin]: "bitcoin", | ||
}; | ||
if (!Object.keys(supportedNetworks).includes(network.name)) | ||
throw new Error("Simplehash: network not supported"); | ||
let allItems: SHOrdinalsNFTType[] = []; | ||
const fetchAll = (continuation?: string): Promise<void> => { | ||
const query = continuation | ||
? continuation | ||
: `${SH_ENDPOINT}owners?chains=${ | ||
supportedNetworks[network.name as keyof typeof supportedNetworks] | ||
}&wallet_addresses=${network.displayAddress(address)}`; | ||
return cacheFetch( | ||
{ | ||
url: query, | ||
}, | ||
CACHE_TTL | ||
).then((json) => { | ||
const items: SHOrdinalsNFTType[] = (json.result as SHOrdinalsResponse) | ||
.nfts; | ||
allItems = allItems.concat(items); | ||
if (json.result.next) return fetchAll(json.result.next); | ||
}); | ||
}; | ||
await fetchAll(); | ||
if (!allItems || !allItems.length) return []; | ||
const collections: Record<string, NFTCollection> = {}; | ||
allItems.forEach((item) => { | ||
const collectionName = | ||
item.extra_metadata.ordinal_details.protocol_name === "brc-20" | ||
? "BRC20" | ||
: item.collection.name | ||
? item.collection.name | ||
: "Unknown"; | ||
const contractAddress = | ||
item.collection.collection_id || item.contract_address; | ||
if (!item.image_url && !item.previews.image_medium_url) return; | ||
if (!collectionName) return; | ||
if (collections[contractAddress]) { | ||
const tItem: NFTItem = { | ||
contract: contractAddress, | ||
id: item.extra_metadata.ordinal_details.location, | ||
image: item.previews.image_medium_url, | ||
name: item.contract.name, | ||
url: `https://ordinals.com/inscription/${item.contract_address}`, | ||
type: NFTType.Ordinals, | ||
}; | ||
collections[contractAddress].items.push(tItem); | ||
} else { | ||
const ret: NFTCollection = { | ||
name: collectionName, | ||
description: item.collection.description, | ||
image: | ||
item.collection.image_url || | ||
require("@action/assets/common/not-found.jpg"), | ||
contract: contractAddress, | ||
items: [ | ||
{ | ||
contract: contractAddress, | ||
id: item.extra_metadata.ordinal_details.location, | ||
image: item.image_url || item.previews.image_medium_url, | ||
name: item.contract.name, | ||
url: `https://ordinals.com/inscription/${item.contract_address}`, | ||
type: NFTType.Ordinals, | ||
}, | ||
], | ||
}; | ||
collections[contractAddress] = ret; | ||
} | ||
}); | ||
return Object.values(collections); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ba254ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Virus total analysis
chrome:
https://www.virustotal.com/gui/file/55fd409805951e27ddab74b389ec27e0c9611bf8631f47faae3a62113f5909d4
firefox:
https://www.virustotal.com/gui/file/179d985db84da4768bb306d69fb394a35fa5f0172722c1e0b143dc834bae3428
ba254ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Virus total analysis
chrome:
https://www.virustotal.com/gui/file/ab4912c9e2987e7837089f81080f6200fc64df40c180f6f39d7d38ab593a83a7
firefox:
https://www.virustotal.com/gui/file/c2f0e1f9de42dbe6c79b5f4e9c2697d937f43939e1e3e362cec4d26454ec625a