@okcontract/sdk
Version:
One-stop-shop permissionless SDK for building any blockchain frontend
78 lines (77 loc) • 3.32 kB
TypeScript
import { type Abi } from "viem";
import type { AnyCell, MapCell } from "@okcontract/cells";
import type { ABI, ABIExtra, CacheQuery } from "@okcontract/coredata";
import type { LocalRPCSubscriber, Network } from "@okcontract/multichain";
import { type Address, type ChainAddress, type ChainType } from "@okcontract/multichain";
import type { LocalSubscriber } from "@scv/cache";
import type { TokenQueryOrAddress } from "./types";
export declare const ERC721 = "721";
export declare const setApprovalForAll_method_signature = "function setApprovalForAll(address to, bool approved) external";
export declare const approve_erc721_method_signature = "function approve(address to, uint256 tokenId) external payable";
/**
* ERC721 ABI.
* @see https://eips.ethereum.org/EIPS/eip-721 to add other methods
*/
export declare const erc721: string[];
export declare const erc721Enumerable: string[];
export declare const erc721Abi: Abi;
export declare const erc721EAbi: Abi;
export declare const abix_erc721: (abi: ABI) => ABIExtra;
/**
* tokenURI retrieves the tokenURI data for a given collection.
* @param coll
* @param id
* @returns
*/
export declare const tokenURI: <Addr extends TokenQueryOrAddress>(rpc: LocalRPCSubscriber, local: LocalSubscriber<CacheQuery>, coll: AnyCell<Addr>, id: AnyCell<number>, chain: AnyCell<ChainType>) => MapCell<string, false>;
export interface ERC721Metadata {
name: string;
description: string;
image: string;
properties?: ERC721Property[];
}
export interface ERC721Property {
trait_type: string;
value: unknown;
max_value?: unknown;
display_type?: "string" | "number";
}
/**
* tokenURI_JSON returns the tokenURI as a JSON.
* @param coll
* @param id
* @param proxy
* @returns
*/
export declare const tokenURI_JSON: (rpc: LocalRPCSubscriber, local: LocalSubscriber<CacheQuery>, chain: AnyCell<ChainType>, coll: AnyCell<Address<Network>>, id: AnyCell<number>, proxy?: string) => AnyCell<ERC721Metadata>;
/**
* returns the owner address of a NFT.
* @param coll
* @param id
* @returns
*/
export declare const owner_of: <Addr extends TokenQueryOrAddress>(rpc: LocalRPCSubscriber, local: LocalSubscriber<CacheQuery>, chain: AnyCell<ChainType>, coll: AnyCell<Addr>, id: number) => MapCell<Address<Network>, false>;
/**
* getPropertyValue retrieves a property from an ERC721 metadata.
* @param m metadata (as retrieved by `tokenURI_JSON`)
* @param key
* @returns
*/
export declare const getPropertyValue: (m: ERC721Metadata, key: string) => unknown;
/**
* fetch_image fetches an image as ObjectURL.
* @param uri
* @param proxy
* @returns
*/
export declare const fetch_image: (uri: string, proxy?: string) => Promise<string>;
/**
* token_image retrieves the image URL for a NFT.
* @param coll
* @param id
* @todo investigate navigator.registerProtocolHandler
*/
export declare const token_image: (rpc: LocalRPCSubscriber, local: LocalSubscriber<CacheQuery>, chain: AnyCell<ChainType>, coll: AnyCell<Address<Network>>, id: AnyCell<number>, proxy?: string) => MapCell<string, false>;
export declare const NFTNbOwned = 1;
export declare const NFTOwned = 2;
export declare const get_owned_nfts: (local: LocalRPCSubscriber, addr: AnyCell<ChainAddress<Network>>, abi: AnyCell<Abi>, owner: AnyCell<Address<Network>>) => MapCell<any, false>;