@okcontract/sdk
Version:
One-stop-shop permissionless SDK for building any blockchain frontend
71 lines (70 loc) • 2.04 kB
TypeScript
import type { Abi, AbiFunction, AbiParameter } from "abitype";
import type { AnyCell, MapCell } from "@okcontract/cells";
import type { Pivot } from "@okcontract/coredata";
import type { AbiOfNetwork, ChainAddress, LocalRPCSubscriber, Network } from "@okcontract/multichain";
/**
* PivotData is cached pivot data, served as an optimization to clients.
* Especially if the range is big (30k for QuickSwap pools!), this data
* should only stay server side and be queryable.
*/
export interface PivotData {
/** contract id */
con: string;
/** range value */
range: number;
/** labels */
labels: {
[key: number]: string;
};
/** display values (e.g. address => name) */
display: {
[key: string]: string;
};
}
/**
* pivot_allowance generates allowances for a pivot.
* @param pivot
* @param extra
* @param inputs
* @param values
* @returns
* @todo compute in environment, not position
* @note not used atm
*/
/**
* PivotFunction defines a pivoted function.
*/
export interface PivotFunction {
/** function name */
name: string;
/** function definition */
fn: AbiFunction;
/** position of the pivot argument */
pos: number;
/** arg (value) name */
arg: string;
/** remaining arguments */
rem: AbiParameter[];
}
/**
* pivotAbi builds a pivot-view of an ABI.
* @param abi
* @param p
*/
export declare const pivotAbi: (abi: Abi, p: Pivot) => PivotFunction[];
export interface PivotView {
funcs: PivotFunction[];
/** current pivot ID */
current: number;
/** max should be the length of labels? */
max: number;
/** labels for each pivot */
labels: string[];
}
/**
* pivot_values gives a list of the pivot values.
* @param abi
* @param p
* @todo pre-compute labels, and retrieve pages from datacache.
*/
export declare const getPivotView: <N extends Network>(rpc: LocalRPCSubscriber, addr: AnyCell<ChainAddress<N>>, abi: AnyCell<AbiOfNetwork<N>>, p: AnyCell<Pivot>, page?: bigint) => MapCell<PivotView, false>;