UNPKG

web3-plugin-superfluid

Version:
91 lines (90 loc) 3.43 kB
import { Contract, Web3PluginBase } from "web3"; import cfav1ForwarderAbi from "./abis/cfav1Forwarder"; import hostAbi from "./abis/host"; import cfav1Abi from "./abis/cfav1"; import idav1Abi from "./abis/idav1"; export type CFAV1Forwarder = Contract<typeof cfav1ForwarderAbi>; export type Host = Contract<typeof hostAbi>; export type CFAV1 = Contract<typeof cfav1Abi>; export type IDAV1 = Contract<typeof idav1Abi>; export interface ProtocolContractAddresses { cfaV1: string; cfaV1Forwarder: string; idaV1: string; host: string; [key: string]: any; } export declare class SuperfluidPlugin extends Web3PluginBase { pluginNamespace: string; /** * This method creates Superfluid's CFAV1Forwarder Contract instance of connected chain * @param address - CFAV1Forwarder Contract Address of connected chain * @returns CFAV1Forwarder Contract instance * @throws Error if address is not a valid address * @example * ```ts * const web3 = new Web3("http://127.0.0.1:8545"); * web3.registerPlugin(new SuperfluidPlugin()); * const cfav1Forwarder = web3.superfluid.cfav1Forwarder(cfav1ForwarderAddress); * ``` */ cfav1Forwarder(address: string): CFAV1Forwarder; /** * This method creates Superfluid's CFAV1 Contract instance of connected chain * @param address - CFAV1 Contract Address of connected chain * @returns CFAV1 Contract instance * @throws Error if address is not a valid address * @example * ```ts * const web3 = new Web3("http://127.0.0.1:8545"); * web3.registerPlugin(new SuperfluidPlugin()); * const cfav1 = web3.superfluid.cfav1(cfav1Address); * ``` */ cfav1(address: string): CFAV1; /** * This method creates Superfluid's IDAV1 Contract instance of connected chain * @param address - IDAV1 Contract Address of connected chain * @returns IDAV1 Contract instance * @throws Error if address is not a valid address * @example * ```ts * const web3 = new Web3("http://127.0.0.1:8545"); * web3.registerPlugin(new SuperfluidPlugin()); * const idav1 = web3.superfluid.idav1(idav1Address); * ``` */ idav1(address: string): IDAV1; /** * This method creates Superfluid's Host Contract instance of connected chain * @param address - Host Contract Address of connected chain * @throws Error if address is not a valid address * @returns Host Contract instance * @example * ```ts * const web3 = new Web3("http://127.0.0.1:8545"); * web3.registerPlugin(new SuperfluidPlugin()); * const host = web3.superfluid.host(hostAddress); * ``` */ host(address: string): Host; /** * This method returns Superfluid protocol contract addresses of given chainId * @param chainId - ChainId of the network to get contract addresses of * @throws Error if chainId is not supported * @returns Protocol contract addresses object * @example * ```ts * const web3 = new Web3("https://rpc-mumbai.maticvigil.com"); * web3.registerPlugin(new SuperfluidPlugin()); * const addresses = web3.superfluid.contractAddresses(80001); * ``` */ contractAddresses(chainId: number): ProtocolContractAddresses; static example(): string; } declare module "web3" { interface Web3Context { superfluid: SuperfluidPlugin; } }