@okcontract/sdk
Version:
One-stop-shop permissionless SDK for building any blockchain frontend
106 lines (105 loc) • 6.78 kB
TypeScript
import type { Abi, TransactionRequest } from "viem";
import { type AnyCell, type MapCell, SheetProxy, type ValueCell } from "@okcontract/cells";
import { type AnonContractQueryType, type CacheQuery, type DataCacheType, type NFTQueryType, type OKWidget, type TokenQueryType } from "@okcontract/coredata";
import type { EditorMode, MapTypeDefinitions } from "@okcontract/fred";
import { Environment, Rational, type StandardLibrary } from "@okcontract/lambdascript";
import type { EnvironmentOptions } from "@okcontract/lambdascript/src/env";
import type { Address, ChainAddress, ChainType, EVMType, Network } from "@okcontract/multichain";
import { type LocalRPCSubscriber, type LogEntry } from "@okcontract/multichain";
import type { LocalSubscriber } from "@scv/cache";
import type { OKData } from "@scv/cache/queryCache";
import { type AnalyzedLog } from "./analyze";
import type { OKCore } from "./coreExecution";
import type { OKContractManager } from "./okcontract";
import { Stepper } from "./stepper";
import type { AnyAddress, ContractQueryType, TokenQueryOrAddress } from "./types";
export type OKPageOptions = {
local?: boolean;
rpc?: boolean;
name?: string;
stdlib?: boolean;
wantedChain?: ValueCell<ChainType>;
onDestroy?: (fn: () => void) => void;
};
export declare class OKPage {
readonly core: OKCore;
readonly proxy: SheetProxy;
readonly local: LocalSubscriber<CacheQuery>;
readonly rpc: LocalRPCSubscriber;
readonly null: MapCell<null, true>;
readonly zero: MapCell<Rational, true>;
readonly wantedChain: ValueCell<ChainType>;
private _stdlib;
private readonly _options;
constructor(core: OKCore, options?: OKPageOptions);
destroy(): void;
_newWeb3Library: () => StandardLibrary;
/**
* envWithWeb3Library adds the complete web3 standard library to an Environment.
* @param instance
* @param env
* @returns
*/
envWithWeb3Library: (env: Environment) => Environment;
newEnvironment: (options?: EnvironmentOptions) => Environment;
_dataCache<Q extends CacheQuery, V = OKData<Q> | null>(q: AnyCell<Q>, opts: {
name?: string;
returnErrors?: boolean;
}): AnyCell<V | null>;
formatAmount(v: AnyCell<number | string | bigint | Rational>, tok: AnyCell<TokenQueryOrAddress>, chain: AnyCell<ChainType>, showSymbol?: AnyCell<boolean>): MapCell<string, false>;
_formatBalance(walletID: AnyCell<Address<Network>>, ch: AnyCell<ChainType>, tok: AnyCell<TokenQueryOrAddress>): MapCell<string, false>;
_getABI(addr: AnyCell<ChainAddress>, abi?: Abi): AnyCell<import("@okcontract/coredata").ABI>;
_rawBalance(wallet: AnyCell<Address<Network>>, ch: AnyCell<ChainType>, tok: AnyCell<TokenQueryOrAddress>): AnyCell<[Rational, Rational, string]>;
_getBalance<N extends Network>(addr: AnyCell<ChainAddress<N>>, owner: AnyCell<Address<N> | null>): MapCell<bigint, false>;
nativeBalance(chain: AnyCell<ChainType>, owner: AnyCell<Address<EVMType> | null>): MapCell<bigint, boolean>;
_getDecimals<N extends Network>(addr: AnyCell<ChainAddress<N>>): MapCell<Rational, false>;
_getSymbol<N extends Network>(addr: AnyCell<ChainAddress<N>>): MapCell<string, false>;
_getName<N extends Network>(addr: AnyCell<ChainAddress<N>>): MapCell<string, false>;
_getAllowanceForWallet(wallet: AnyCell<Address<Network>>, addr: AnyCell<ChainAddress>, spender: AnyCell<Address<Network>>): AnyCell<bigint>;
logTitle(wallet: AnyCell<Address<Network>>, aLog: AnyCell<AnalyzedLog>): MapCell<string[], false>;
logSearch<Prop extends string | null, Emitter extends AnyAddress | null, Filter extends {
[k: string]: string | Address<Network> | number | bigint;
} | null>(chain: AnyCell<ChainType>, logs: AnyCell<AnalyzedLog[][]>, step: AnyCell<number>, event: AnyCell<string>, prop: AnyCell<Prop>, emitter: AnyCell<Emitter>, filter: AnyCell<Filter>): MapCell<unknown, false>;
analyzeLog(log: AnyCell<LogEntry>, ch: AnyCell<ChainType>): AnyCell<AnalyzedLog>;
analyzeLogs(chain: AnyCell<ChainType>, logsCell: AnyCell<AnyCell<LogEntry>[]>): MapCell<MapCell<AnalyzedLog, false>[], false>;
_retrieveAddress<Source extends AnyAddress>(ch: AnyCell<ChainType>, addr: AnyCell<Source>): MapCell<Source extends AnyAddress ? Address<Network> : Source, false>;
_retrieveAllAddresses(ch: AnyCell<ChainType>, l: AnyCell<AnyCell<AnyAddress>[]>): MapCell<ValueCell<unknown>[], false>;
_generateTX(addr: AnyCell<ChainAddress>, data: AnyCell<`0x${string}`>, value: AnyCell<Rational>, estimateGas?: boolean): MapCell<{
tx: {
from: `0x${string}` | import("@okcontract/multichain/src/address").StringAddressTON;
to: `0x${string}` | import("@okcontract/multichain/src/address").StringAddressTON;
data: `0x${string}`;
value: `0x${string}`;
};
}, false>;
_estimateGas(ch: AnyCell<ChainType>, tx: AnyCell<TransactionRequest>): AnyCell<bigint>;
_proxyFetch(uri: AnyCell<string>): AnyCell<Response>;
proxyHead(uri: AnyCell<string>): AnyCell<Response>;
_findName(ch: AnyCell<ChainType>, addr: AnyCell<Address<Network>>): MapCell<string, boolean>;
dataTypeScheme(isAdmin?: boolean, mode?: EditorMode, type?: DataCacheType, methods?: string[]): MapTypeDefinitions;
newInteraction(types: MapTypeDefinitions, contractQuery?: TokenQueryType | ContractQueryType | AnonContractQueryType<ChainType>, method?: string): Promise<import("./widget").OKWidgetData>;
newInteractionFrom(types: MapTypeDefinitions, from: OKWidget): Promise<import("./widget").OKWidgetData>;
_callMethod<Args extends AnyCell<unknown>[]>(chain: AnyCell<ChainType>, q: AnyCell<AnyAddress>, meth: AnyCell<string>, args: AnyCell<Args>): Promise<MapCell<unknown, false>>;
_tokenImage(chain: AnyCell<ChainType>, coll: AnyCell<Address<Network>>, id: AnyCell<number>, proxy?: string): MapCell<string, false>;
_tokenURI(chain: AnyCell<ChainType>, coll: AnyCell<Address<Network>>, id: AnyCell<number>, proxy?: string): AnyCell<import("./erc721").ERC721Metadata>;
_ownerOf(chain: AnyCell<ChainType>, coll: AnyCell<NFTQueryType | Address<Network>>, id: number): MapCell<Address<Network>, false>;
/**
* stepper instanciates a new Stepper
*/
stepper(id: string): Stepper;
/**
* Create new Stepper.
* @param okc manager
* @param wid widget ID
* @param chain wanted chain
* @returns
* @todo merge with previous
*/
_NewStepper(okc: OKContractManager, wid: string): Stepper;
fork(name: string): OKPage;
}
export declare const buildTX: (core: OKCore, id: string) => Promise<{
page: OKPage;
stepper: Stepper;
tx: import("./oktransaction").OKTransaction<import("./okcontract").AnyContractQuery>;
}>;