@open-social-protocol/osp-plugin-api-types
Version:
API types for Open Social Protocol plugins
92 lines (74 loc) • 2.05 kB
TypeScript
// 模版风格
export type TempleteNames = "imgWithBtns" | "vote";
export type PageType = "create" | "detail" | "ssr"
export type PageMode = "card" | "page"
type HttpUrl = string;
export interface TempleteImgWithBtns {
type: "imgWithBtns";
data: {
media?: {
type: "image";
url: HttpUrl;
width: number;
height: number;
};
buttons?: string[];
};
}
export interface TempleteVote {
type: "vote";
data: {};
}
export type TCreatePluginInfo = Pick<
TPluginInfo,
"preview" | "extensionData"| "opensocial" | "addition"
>;
// 插件模板UI需要的参数
export type TPluginTemplate = TempleteImgWithBtns | TempleteVote;
export type TPluginData = {
address: string;
call_data: string;
value: BigNumberish;
};
interface MetadataAttribute {
type: "Object";
key: TempleteNames;
value: object;
}
//pluginUI.createOspPostData: 点done时候 -> plugin 信息
export type TPluginInfo = {
id: string;
name: string;
preview?: TPluginTemplate; // 插件业务上使用的参数
extensionData?: TPluginData; // ethers.utils.defaultAbiCoder.encode 加密过的数据
// ipfs 上链属性, osp生态项目使用
addition?: {
[key: string]: any
}
opensocial?: {
extensions: MetadataAttribute[] ;
/**
* pattern: "^[a-z]{2}(?:-[a-zA-Z]{2})?$";
* description: "A Locale Identifier in the `[language]` OR `[language]-[region]` format (e.g. `en`, `en-GB`, `it`). [language] MUST be in the ISO 639-1 format. [region], if provided, MUST be in the ISO 3166-1 alpha-2 format.";
*/
locale: string;
}
};
export type TPluginMessage = {
action: string;
payload?: object;
};
export type TPluginTransaction = {
assetChangeList : {
assetAddress: string;
type: "ERC20" | "NATIVE" | "ERC721";
from: string;
to: string;
rawAmount: string;
decimals?: number;
amount?: string;
}[],
gas: string,
approveParams?: ApproveParamsType
};
export type ApproveParamsType = { tokenAddress: string, amount: string, spender: string }