Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
nft-openaction-kit
Advanced tools
Seamless integration of NFT platforms into the Lens protocol by enabling automatic detection and handling of NFT links within Lens publications.
The nft-openaction-kit package simplifies the process of integrating an NFT minting open action into Lens applications. This package has two core functionalities:
When a user posts a link to an NFT in a Lens Publication, this package will parse data from the URL and smart contracts to embed an NFT minting open action into the Lens Publication.
When a post appears in a Lens application feed with the NFT minting action attached, the app can use this package to populate metadata to appear on a UI and generate calldata to perform the transaction.
detectAndReturnCalldata
. Detects the NFT platform and returns the calldata to be used in the post action.actionDataFromPost
. Returns the encoded calldata from Decent and UI data for the post action.IPlatformService
interface.
actionDataFromPost
is returingundefined
as the actionResponse from Decent is empty.
The route from Polygon to Zora is not configured in the Decent API.
Clone the repo
git clone https://github.com/0xnogo/nft-openAction-kit.git
Install NPM packages
yarn install
Build
yarn build
The package is not published. To use is locally, run
yarn link
in the root directory andyarn link nft-openaction-kit
in the project you want to use it.
Create a .env file in the root directory and add the following variables:
DECENT_API_KEY=api-key
RARIBLE_API_KEY=api-key
OPENSEA_API_KEY=api-key
Instantiate the NFTOpenActionKit
class and use the detectAndReturnCalldata
and actionDataFromPost
methods.
import { NftOpenActionKit } from "nft-openaction-kit";
const nftOpenActionKit = new NftOpenActionKit({
decentApiKey: process.env.DECENT_API_KEY,
raribleApiKey: process.env.RARIBLE_API_KEY,
openSeaApiKey: process.env.OPENSEA_API_KEY,
});
Only the
decentApiKey
is required. TheraribleApiKey
andopenSeaApiKey
are optional, which would make the detection available for these platforms.
detectAndReturnCalldata
const fetchCalldata = async () => {
try {
const result = await nftOpenActionKit.detectAndReturnCalldata({
contentURI: url,
publishingClientProfileId: "10",
});
console.log(result || "No calldata found");
} catch (err) {
console.log(err);
}
};
actionDataFromPost
const publication = {
profileId: "48935",
actionModules: ["0x99Cd5A6e51C85CCc63BeC61A177003A551953628"],
actionModulesInitDatas: [calldata],
pubId: "10",
};
try {
// Call the async function and pass the link
const result: ActionData = await nftOpenActionKit.actionDataFromPost({
post: publication,
profileId,
profileOwnerAddress,
senderAddress,
srcChainId,
quantity,
paymentToken,
executingClientProfileId,
mirrorerProfileId,
mirrorPubId,
});
} catch (error) {
console.log(error);
}
The
actionDataFromPost
function is accepting a subset of fields from Publication events (example event defined in https://github.com/wkantaros/lens-openAction).
src/types/index.ts
:type SdkConfig = {
decentApiKey: string,
raribleApiKey?: string,
openSeaApiKey?: string,
};
src/DetectionEngine.ts
and add the new platform config following the type:type NFTPlatform = {
platformName: string,
platformLogoUrl: string,
urlPattern: RegExp,
urlExtractor: (url: string) => Promise<NFTExtraction | undefined>,
platformService: PlatformServiceConstructor,
};
src/platform
and add the platform service class. The class should implement the IPlatformService
interface.export type NFTPlatform = {
platformName: string,
platformLogoUrl: string,
urlPattern: RegExp,
urlExtractor: (url: string) => Promise<NFTExtraction | undefined>,
urlExtractor: (url: string) => Promise<NFTExtraction | undefined>,
platformService: PlatformServiceConstructor,
apiKey?: string,
};
If an api key is required, make sure to add it in the
DetectionEngine
class and handle it in theinitializePlatformConfig
function. The Rareble detection is an example of how to handle an api key.
src/platform
and add the platform service class. The class should implement the IPlatformService
interface.interface IPlatformService {
platformName: string;
getMinterAddress(
contract: string,
tokenId: bigint
): Promise<string | undefined>;
getMintSignature(nftDetails: NFTExtraction): Promise<string | undefined>;
getUIData(
signature: string,
contract: string,
tokenId: bigint,
dstChainId: bigint
): Promise<UIData | undefined>;
getPrice(
contractAddress: string,
nftId: bigint,
signature: string,
userAddress: string,
unit?: bigint
): Promise<bigint | undefined>;
getArgs(
contractAddress: string,
tokenId: bigint,
senderAddress: string,
signature: string,
price: bigint,
quantity: bigint,
profileOwnerAddress: string
): Promise<any[]>;
}
FAQs
Seamless integration of NFT platforms into the Lens protocol by enabling automatic detection and handling of NFT links within Lens publications.
The npm package nft-openaction-kit receives a total of 430 weekly downloads. As such, nft-openaction-kit popularity was classified as not popular.
We found that nft-openaction-kit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.