diff --git a/packages/js-sdk/src/ConstantFlowAgreementV1Helper.d.ts b/packages/js-sdk/src/ConstantFlowAgreementV1Helper.d.ts index 4c1e28acfc..018c3b1875 100644 --- a/packages/js-sdk/src/ConstantFlowAgreementV1Helper.d.ts +++ b/packages/js-sdk/src/ConstantFlowAgreementV1Helper.d.ts @@ -1,6 +1,7 @@ -import { Transaction } from "web3-core"; -import Framework from "./Framework"; +import type { Transaction } from "web3-core"; +import type { Framework } from "./Framework"; import type { LoadedContract } from "./loadContracts"; +import type BN from 'bn.js'; export type Flow = { sender: string; @@ -20,10 +21,10 @@ export declare class ConstantFlowAgreementV1Helper { deposit, owedDeposit, }: { - timestamp: any; - flowRate: any; - deposit: any; - owedDeposit: any; + timestamp: number | BN; + flowRate: number | BN; + deposit: number | BN; + owedDeposit: number | BN; }): { timestamp: Date; flowRate: string; @@ -61,7 +62,7 @@ export declare class ConstantFlowAgreementV1Helper { sender: string; receiver: string; flowRate: string; - userData: any; + userData: string; onTransaction: () => void; }): Promise; /** @@ -86,7 +87,7 @@ export declare class ConstantFlowAgreementV1Helper { sender: string; receiver: string; flowRate: string; - userData: any; + userData: string; onTransaction: () => void; }): Promise; /** @@ -111,7 +112,7 @@ export declare class ConstantFlowAgreementV1Helper { sender: string; receiver: string; by: string; - userData: any; + userData: string; onTransaction: () => void; }): Promise; /** diff --git a/packages/js-sdk/src/Framework.d.ts b/packages/js-sdk/src/Framework.d.ts index ea54155435..b5f4dcf093 100644 --- a/packages/js-sdk/src/Framework.d.ts +++ b/packages/js-sdk/src/Framework.d.ts @@ -1,11 +1,11 @@ import type Web3 from "web3"; -import ConstantFlowAgreementV1Helper from "./ConstantFlowAgreementV1Helper"; -import InstantDistributionAgreementV1Helper from "./InstantDistributionAgreementV1Helper"; -import GasMeter from "./utils/gasMetering/gasMetering"; +import type { ConstantFlowAgreementV1Helper } from "./ConstantFlowAgreementV1Helper"; +import type { InstantDistributionAgreementV1Helper } from "./InstantDistributionAgreementV1Helper"; +import type { GasMeter, Record } from "./utils/gasMetering/gasMetering"; import LoadContracts from "./loadContracts"; import Config from "./getConfig"; -import User from "./User"; -import Utils from "./Utils"; +import type { User } from "./User"; +import type { Utils } from "./Utils"; declare type GasReportTypeOptions = 'JSON' | 'HTML' | 'TENDERLY'; @@ -47,7 +47,7 @@ export declare class Framework { utils: Utils | undefined; _gasMetering: GasMeter | undefined; - initialize(): Promise; + initialize(): Promise; isSuperTokenListed(superTokenKey: string): Promise; loadToken(tokenKey: string): Promise; createERC20Wrapper(tokenInfo: any, @@ -64,6 +64,6 @@ export declare class Framework { options?: any; }): User; batchCall(calls: any): any; - _pushTxForGasReport(tx: GasMeter.Record, actionName: string): void; + _pushTxForGasReport(tx: Record, actionName: string): void; generateGasReport(name: string): void; } diff --git a/packages/js-sdk/src/InstantDistributionAgreementV1Helper.d.ts b/packages/js-sdk/src/InstantDistributionAgreementV1Helper.d.ts index dfe96a3aff..1302bb55b9 100644 --- a/packages/js-sdk/src/InstantDistributionAgreementV1Helper.d.ts +++ b/packages/js-sdk/src/InstantDistributionAgreementV1Helper.d.ts @@ -1,5 +1,5 @@ -import { Transaction } from "web3-core"; -import Framework from "./Framework"; +import type { Transaction } from "web3-core"; +import type { Framework } from "./Framework"; import type { LoadedContract } from "./loadContracts"; import type BN from 'bn.js'; @@ -13,9 +13,9 @@ export interface Subscription { export declare class InstantDistributionAgreementV1Helper { static _sanitizeIndexData({ exist, indexValue, totalUnitsApproved, totalUnitsPending, }: { exist: boolean; - indexValue: any; - totalUnitsApproved: any; - totalUnitsPending: any; + indexValue: number | BN; + totalUnitsApproved: number | BN; + totalUnitsPending: number | BN; }): { exist: boolean; indexValue: string; @@ -25,8 +25,8 @@ export declare class InstantDistributionAgreementV1Helper { static _sanitizeSubscriptionData({ exist, approved, units, pendingDistribution, }: { exist: boolean; approved: boolean; - units: any; - pendingDistribution: any; + units: number | BN; + pendingDistribution: number | BN; }): { exist: boolean; approved: boolean; @@ -35,8 +35,8 @@ export declare class InstantDistributionAgreementV1Helper { }; static _sanitizeSubscriptionInfo({ publishers, indexIds, unitsList }: { publishers: any[]; - indexIds: any; - unitsList: any; + indexIds: number | BN; + unitsList: number | BN; }): { publisher: string; indexId: string; @@ -63,7 +63,7 @@ export declare class InstantDistributionAgreementV1Helper { superToken: string; publisher: string; indexId: number; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** @@ -80,7 +80,7 @@ export declare class InstantDistributionAgreementV1Helper { publisher: string; indexId: number; amount: BN; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** @@ -100,7 +100,7 @@ export declare class InstantDistributionAgreementV1Helper { publisher: string; indexId: number; indexValue: BN; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** @@ -119,7 +119,7 @@ export declare class InstantDistributionAgreementV1Helper { indexId: number; subscriber: string; units: BN; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** @@ -140,7 +140,7 @@ export declare class InstantDistributionAgreementV1Helper { publisher: string; indexId: number; subscriber: string; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** @@ -160,7 +160,7 @@ export declare class InstantDistributionAgreementV1Helper { indexId: number; publisher: string; subscriber: string; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** @@ -182,7 +182,7 @@ export declare class InstantDistributionAgreementV1Helper { publisher: string; subscriber: string; sender: string; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** @@ -218,7 +218,7 @@ export declare class InstantDistributionAgreementV1Helper { indexId: number; subscriber: string; sender: string; - userData: any; + userData: string; onTransaction: () => any; }): Promise; /** diff --git a/packages/js-sdk/src/User.d.ts b/packages/js-sdk/src/User.d.ts index 15264c4b32..479fbe04cb 100644 --- a/packages/js-sdk/src/User.d.ts +++ b/packages/js-sdk/src/User.d.ts @@ -1,7 +1,8 @@ -import type Framework from './Framework'; -import type BN from 'bn'; -import Transaction from 'web3'; -import type { Flow } from './ConstantFlowAgreementV1Helper' +import type { Framework } from './Framework'; +import type BN from 'bn.js'; +import type { Transaction } from 'web3'; +import type { Flow } from './ConstantFlowAgreementV1Helper'; +import type { Subscription } from './InstantDistributionAgreementV1Helper'; export type DetailsType = { cfa: { diff --git a/packages/js-sdk/src/Utils.d.ts b/packages/js-sdk/src/Utils.d.ts index 38cca64f57..80646926d7 100644 --- a/packages/js-sdk/src/Utils.d.ts +++ b/packages/js-sdk/src/Utils.d.ts @@ -1,5 +1,5 @@ -import Framework from "./Framework"; -import type BN from 'bn.js' +import type { Framework } from "./Framework"; +import type BN from 'bn.js'; export declare class Utils { constructor(sf: Framework); _sf: Framework; diff --git a/packages/js-sdk/src/batchCall.d.ts b/packages/js-sdk/src/batchCall.d.ts index fe285ed544..c04347c821 100644 --- a/packages/js-sdk/src/batchCall.d.ts +++ b/packages/js-sdk/src/batchCall.d.ts @@ -1,5 +1,5 @@ // TODO set batchCall return type -import { Transaction } from 'web3-core' +import type { Transaction } from 'web3-core' // ERC20 Approve/TransferFrom type ERC20OperationType = 'ERC20_APPROVE'| 'ERC20_TRANSFER_FROM' | 1 | 2; diff --git a/packages/js-sdk/src/index.d.ts b/packages/js-sdk/src/index.d.ts index 3ab726e5b8..7e313c6a34 100644 --- a/packages/js-sdk/src/index.d.ts +++ b/packages/js-sdk/src/index.d.ts @@ -1,16 +1,6 @@ -export const getConfig: (chainId: any) => any; -export const loadContracts: ({ isTruffle, ethers, web3, from, additionalContracts, contractLoader, networkId, }: { - isTruffle: any; - ethers: any; - web3: any; - from: any; - additionalContracts: any; - contractLoader: any; - networkId: any; -}) => Promise<{}>; -export const Framework: { - new (options: any): import("./Framework"); -}; +export type { getConfig } from './getConfig'; +export type { loadContracts } from './loadContracts'; +export type { Framework } from './Framework'; export type { Record } from './utils/gasMetering/gasMetering'; diff --git a/packages/js-sdk/src/loadContracts.d.ts b/packages/js-sdk/src/loadContracts.d.ts index cb6f17580d..50e9614927 100644 --- a/packages/js-sdk/src/loadContracts.d.ts +++ b/packages/js-sdk/src/loadContracts.d.ts @@ -1,8 +1,33 @@ -import { ethers, Contract as EthersContract, utils } from "ethers"; +import type { ethers, Contract as EthersContract, utils, ContractInterface } from "ethers"; import type { Contract as Web3Contract } from "web3-eth-contract"; import TruffleContract from "@truffle/contract"; import type Web3 from "web3"; +type SuperfluidContractNames = + | 'ERC20WithTokenInfo' + | 'IConstantFlowAgreementV1' + | 'IERC20' + | 'IInstantDistributionAgreementV1' + | 'IResolver' + | 'ISETH' + | 'ISuperAgreement' + | 'ISuperToken' + | 'ISuperTokenFactory' + | 'ISuperfluid' + | 'ISuperfluidGovernance' + | 'SuperfluidLoader' + | 'TestToken' + | 'TokenInfo' + | 'UUPSProxiable'; + +export type SuperfluidContractObject = { + abi: ContractInterface; + contractName: SuperfluidContractNames; + at: (address: string) => EthersContract; +} + +export type SuperfluidContracts = Record + export interface EthersWithSigner { getSigner(): () => any } @@ -30,4 +55,4 @@ export declare function loadContracts({ isTruffle, ethers, web3, from, additiona additionalContracts?: string[]; contractLoader: ContractLoader; networkId: number; -}): Promise; +}): Promise; diff --git a/packages/js-sdk/src/utils/gasMetering/gasMetering.d.ts b/packages/js-sdk/src/utils/gasMetering/gasMetering.d.ts index a5127df31d..42093fd99e 100644 --- a/packages/js-sdk/src/utils/gasMetering/gasMetering.d.ts +++ b/packages/js-sdk/src/utils/gasMetering/gasMetering.d.ts @@ -1,7 +1,7 @@ import type BN from 'bn.js' import type Web3 from 'web3' -import { GasMeterJSONReporter } from "./gasReporter"; -import { GasMeterHTMLReporter } from "./gasReporter"; +import type { GasMeterJSONReporter } from "./gasReporter"; +import type { GasMeterHTMLReporter } from "./gasReporter"; export type Record = { action: string @@ -11,8 +11,7 @@ export type Record = { cost: BN } -export = GasMeter; -declare class GasMeter { +export declare class GasMeter { constructor( web3: Web3, outputFormat: 'JSON'|'HTML'|'TENDERLY', diff --git a/packages/js-sdk/src/utils/general.d.ts b/packages/js-sdk/src/utils/general.d.ts index 607a25c47d..b81036975b 100644 --- a/packages/js-sdk/src/utils/general.d.ts +++ b/packages/js-sdk/src/utils/general.d.ts @@ -1,5 +1,5 @@ -import type Framework from '../Framework' -import { Transaction } from 'web3-core' +import type { Framework } from '../Framework'; +import type { Transaction } from 'web3-core'; export function validateAddress(address: string): void; export function isAddress(address: string): boolean; diff --git a/tsconfig.json b/packages/js-sdk/tsconfig.json similarity index 98% rename from tsconfig.json rename to packages/js-sdk/tsconfig.json index cecd60adfd..62baa23b61 100644 --- a/tsconfig.json +++ b/packages/js-sdk/tsconfig.json @@ -1,16 +1,19 @@ { "include": [ - "./packages/js-sdk/src/*" + "./src/" + ], + "exclude": [ + "dist", + "node_modules", + "reports", ], "compilerOptions": { /* Visit https://aka.ms/tsconfig.json to read more about this file */ - "types": [ "bn.js", "web3", "node" ], - /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */