Skip to content

Commit

Permalink
Fix typescript typing issues (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtriley2p authored Sep 20, 2021
1 parent 9059838 commit 1cf5a8b
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 64 deletions.
19 changes: 10 additions & 9 deletions packages/js-sdk/src/ConstantFlowAgreementV1Helper.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -61,7 +62,7 @@ export declare class ConstantFlowAgreementV1Helper {
sender: string;
receiver: string;
flowRate: string;
userData: any;
userData: string;
onTransaction: () => void;
}): Promise<Transaction>;
/**
Expand All @@ -86,7 +87,7 @@ export declare class ConstantFlowAgreementV1Helper {
sender: string;
receiver: string;
flowRate: string;
userData: any;
userData: string;
onTransaction: () => void;
}): Promise<Transaction>;
/**
Expand All @@ -111,7 +112,7 @@ export declare class ConstantFlowAgreementV1Helper {
sender: string;
receiver: string;
by: string;
userData: any;
userData: string;
onTransaction: () => void;
}): Promise<Transaction>;
/**
Expand Down
14 changes: 7 additions & 7 deletions packages/js-sdk/src/Framework.d.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -47,7 +47,7 @@ export declare class Framework {
utils: Utils | undefined;
_gasMetering: GasMeter | undefined;

initialize(): Promise<any>;
initialize(): Promise<void>;
isSuperTokenListed(superTokenKey: string): Promise<boolean>;
loadToken(tokenKey: string): Promise<void>;
createERC20Wrapper(tokenInfo: any,
Expand All @@ -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;
}
34 changes: 17 additions & 17 deletions packages/js-sdk/src/InstantDistributionAgreementV1Helper.d.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -63,7 +63,7 @@ export declare class InstantDistributionAgreementV1Helper {
superToken: string;
publisher: string;
indexId: number;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand All @@ -80,7 +80,7 @@ export declare class InstantDistributionAgreementV1Helper {
publisher: string;
indexId: number;
amount: BN;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand All @@ -100,7 +100,7 @@ export declare class InstantDistributionAgreementV1Helper {
publisher: string;
indexId: number;
indexValue: BN;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand All @@ -119,7 +119,7 @@ export declare class InstantDistributionAgreementV1Helper {
indexId: number;
subscriber: string;
units: BN;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand All @@ -140,7 +140,7 @@ export declare class InstantDistributionAgreementV1Helper {
publisher: string;
indexId: number;
subscriber: string;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand All @@ -160,7 +160,7 @@ export declare class InstantDistributionAgreementV1Helper {
indexId: number;
publisher: string;
subscriber: string;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand All @@ -182,7 +182,7 @@ export declare class InstantDistributionAgreementV1Helper {
publisher: string;
subscriber: string;
sender: string;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand Down Expand Up @@ -218,7 +218,7 @@ export declare class InstantDistributionAgreementV1Helper {
indexId: number;
subscriber: string;
sender: string;
userData: any;
userData: string;
onTransaction: () => any;
}): Promise<Transaction>;
/**
Expand Down
9 changes: 5 additions & 4 deletions packages/js-sdk/src/User.d.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions packages/js-sdk/src/Utils.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/src/batchCall.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
16 changes: 3 additions & 13 deletions packages/js-sdk/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
29 changes: 27 additions & 2 deletions packages/js-sdk/src/loadContracts.d.ts
Original file line number Diff line number Diff line change
@@ -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<SuperfluidContractNames, SuperfluidContractObject>

export interface EthersWithSigner {
getSigner(): () => any
}
Expand Down Expand Up @@ -30,4 +55,4 @@ export declare function loadContracts({ isTruffle, ethers, web3, from, additiona
additionalContracts?: string[];
contractLoader: ContractLoader;
networkId: number;
}): Promise<LoadedContract[]>;
}): Promise<SuperfluidContracts>;
7 changes: 3 additions & 4 deletions packages/js-sdk/src/utils/gasMetering/gasMetering.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions packages/js-sdk/src/utils/general.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 6 additions & 3 deletions tsconfig.json → packages/js-sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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'. */
Expand Down

0 comments on commit 1cf5a8b

Please sign in to comment.