Skip to content

Commit

Permalink
[ETHEREUM-CONTRACTS/SDK-CORE] Remove typechain from build output (#1681)
Browse files Browse the repository at this point in the history
* remove build/typechain-types

* fix formatting

* fix up shell script

* Update build-types.sh
  • Loading branch information
0xdavinchee authored Sep 19, 2023
1 parent 21785e7 commit 048af58
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 48 deletions.
2 changes: 2 additions & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Breaking
- `TokenInfo` and `ERC20WithTokenInfo` interface/abstract contract are removed from the codebase, including the bundled ABI contracts
- Migration: Use `IERC20Metadata` instead, as this replaces the previous contracts
- `build/typechain-ethers-v5` is removed from the npm package
- Migration: Consume the ABIs and utilize whatever tool you'd like to generate types from them

### Added

Expand Down
2 changes: 0 additions & 2 deletions packages/ethereum-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"!/build/truffle/*Tester*.json",
"!/build/truffle/*Anvil.json",
"!/build/truffle/*Properties.json",
"/build/typechain-ethers-v5/**/*",
"/build/contracts-sizes.txt",
"/build/bundled-abi.js",
"/build/bundled-abi.json",
Expand All @@ -43,7 +42,6 @@
"build:contracts:foundry": "yarn run-foundry build",
"build:post-contracts": "run-p -l build:post-contracts:*",
"build:post-contracts:abi-bundle": "tasks/build-bundled-abi.sh",
"build:post-contracts:typechain-ethers-v5": "tsc -p tsconfig.typechain.json",
"build:post-contracts:dev-scripts-typings": "rm -rf dev-scripts/*.d.ts dev-scripts/*.d.ts.map; tsc -p tsconfig.scripts.json",
"build:post-contracts:contracts-size": "forge build --sizes > build/contracts-sizes.txt",
"verify-framework": "tasks/etherscan-verify-framework.sh",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-core/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ dist
build
coverage
cache
src/typechain
src/typechain-types
src/abi
**/*.generated.*
**/*.generated.*
3 changes: 2 additions & 1 deletion packages/sdk-core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage
/src/typechain
*.generated.ts
/typechain-types
/artifacts
/artifacts
src/typechain-types
1 change: 1 addition & 0 deletions packages/sdk-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
],
"scripts": {
"build": "yarn generate && rm -rf dist && run-s build:*",
"build:typechain-types": "./tasks/build-types.sh",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"build:umd": "mkdir -p dist && browserify src/index.ts -s sdkCore -p [ tsify --noImplicitAny --skipLibCheck ] > dist/index.umd.js",
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk-core/src/ConstantFlowAgreementV1.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import {
CFAv1Forwarder,
CFAv1Forwarder__factory,
IConstantFlowAgreementV1,
IConstantFlowAgreementV1__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers } from "ethers";

import Host from "./Host";
Expand All @@ -28,6 +22,12 @@ import {
IWeb3FlowOperatorData,
IWeb3FlowOperatorDataParams,
} from "./interfaces";
import {
CFAv1Forwarder,
CFAv1Forwarder__factory,
IConstantFlowAgreementV1,
IConstantFlowAgreementV1__factory,
} from "./typechain-types";
import {
getSanitizedTimestamp,
isPermissionsClean,
Expand Down
5 changes: 1 addition & 4 deletions packages/sdk-core/src/ERC20Token.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import {
IERC20Metadata,
IERC20Metadata__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers } from "ethers";

import Operation from "./Operation";
import { SFError } from "./SFError";
import { IBaseSuperTokenParams, ITransferFromParams } from "./interfaces";
import { IERC20Metadata, IERC20Metadata__factory } from "./typechain-types";
import { normalizeAddress } from "./utils";

export default class ERC20Token {
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk-core/src/Framework.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types";
import {
Resolver,
Resolver__factory,
Superfluid__factory,
SuperfluidLoader__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers } from "ethers";
import Web3 from "web3";

Expand All @@ -28,6 +22,12 @@ import {
validateFrameworkConstructorOptions,
} from "./frameworkHelpers";
import { IConfig, IContracts, ISignerConstructorOptions } from "./interfaces";
import {
Resolver,
Resolver__factory,
Superfluid__factory,
SuperfluidLoader__factory,
} from "./typechain-types";
import { isEthersProvider, isInjectedWeb3 } from "./utils";

const V1 = "v1";
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-core/src/Governance.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
SuperfluidGovernanceII,
SuperfluidGovernanceII__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers } from "ethers";

import {
IGetGovernanceParametersParams,
IWeb3GovernanceParams,
} from "./interfaces";
import {
SuperfluidGovernanceII,
SuperfluidGovernanceII__factory,
} from "./typechain-types";

export default class Governance {
contract: SuperfluidGovernanceII;
Expand Down
5 changes: 1 addition & 4 deletions packages/sdk-core/src/Host.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {
Superfluid,
Superfluid__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers, Overrides } from "ethers";

import Operation from "./Operation";
import { Superfluid, Superfluid__factory } from "./typechain-types";

/**
* Host Helper Class
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-core/src/InstantDistributionAgreementV1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import {
IInstantDistributionAgreementV1,
IInstantDistributionAgreementV1__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers } from "ethers";

import Host from "./Host";
Expand All @@ -21,6 +17,10 @@ import {
IWeb3Index,
IWeb3Subscription,
} from "./interfaces";
import {
IInstantDistributionAgreementV1,
IInstantDistributionAgreementV1__factory,
} from "./typechain-types";
import { normalizeAddress } from "./utils";

const idaInterface = IInstantDistributionAgreementV1__factory.createInterface();
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-core/src/Operation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Superfluid__factory } from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers } from "ethers";

import {
Expand All @@ -8,6 +7,7 @@ import {
} from "./BatchCall";
import { SFError } from "./SFError";
import multiplyGasLimit from "./multiplyGasLimit";
import { Superfluid__factory } from "./typechain-types";
import { removeSigHashFromCallData } from "./utils";

export type BatchOperationType =
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk-core/src/SuperToken.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import {
ISETH,
ISETH__factory,
ISuperToken,
ISuperToken__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { BytesLike, ethers, Overrides } from "ethers";

import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
Expand Down Expand Up @@ -48,6 +42,12 @@ import {
SuperTokenFlowRateAllowanceParams,
SuperTokenFlowRateAllowanceWithPermissionsParams,
} from "./interfaces";
import {
ISETH,
ISETH__factory,
ISuperToken,
ISuperToken__factory,
} from "./typechain-types";
import {
getSanitizedTimestamp,
getStringCurrentTimeInSeconds,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export * from "./pagination";
export * from "./ordering";
export * from "./events";
export * from "./types";
export * from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
export * from "./typechain-types";

export { Operation, BatchOperationType as OperationType };
export { BatchCall };
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-core/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ethers, Overrides } from "ethers";

import {
IConstantFlowAgreementV1,
IInstantDistributionAgreementV1,
IResolver,
Superfluid,
SuperfluidGovernanceII,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { ethers, Overrides } from "ethers";
} from "./typechain-types";

// TODO (0xdavinchee): reorganize this
// Maybe moving these into categorical files
Expand Down
19 changes: 19 additions & 0 deletions packages/sdk-core/tasks/build-types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# make sure that if any step fails, the script fails
set -xe

rm -rf ./src/typechain-types

# if the typechain files do not exist, we build
# hardhat so that it does exist
if [ ! -d "../ethereum-contracts/typechain-types" ]; then
echo "typechain-types does not exist: You must build ethereum-contracts first to generate it."
exit 1
fi

# copy the typechain files over from ethereum-contracts
cp -r ../ethereum-contracts/typechain-types ./src/typechain-types

# compile the typechain files in sdk-core
tsc -p tsconfig.typechain.json
2 changes: 1 addition & 1 deletion packages/sdk-core/test/2_operation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { Framework } from "../src/index";
import { getPerSecondFlowRateByMonth } from "../src";
import { IConstantFlowAgreementV1__factory } from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
import { IConstantFlowAgreementV1__factory } from "../src/typechain-types";
import Operation from "../src/Operation";
import hre from "hardhat";
import { SuperAppTester } from "../typechain-types";
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-core/test/TestEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SuperfluidFrameworkDeployer,
TestToken,
TestToken__factory,
} from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5";
} from "../src/typechain-types";
import {
Framework,
NativeAssetSuperToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"extends": "./tsconfig",
"compilerOptions": {
"target": "ES2019",
"outDir": "build/typechain-ethers-v5",
"outDir": "src/typechain-types",
"moduleResolution": "node",
"module": "CommonJS",
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"files": [],
"include": ["typechain-types"],
"include": ["src/typechain-types"],
"exclude": ["node_modules/**"]
}
}

0 comments on commit 048af58

Please sign in to comment.