diff --git a/packages/ethereum-contracts/CHANGELOG.md b/packages/ethereum-contracts/CHANGELOG.md index 416512776a..aea245ab03 100644 --- a/packages/ethereum-contracts/CHANGELOG.md +++ b/packages/ethereum-contracts/CHANGELOG.md @@ -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 diff --git a/packages/ethereum-contracts/package.json b/packages/ethereum-contracts/package.json index b92ce59da5..0c01f3eb8d 100644 --- a/packages/ethereum-contracts/package.json +++ b/packages/ethereum-contracts/package.json @@ -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", @@ -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", diff --git a/packages/sdk-core/.eslintignore b/packages/sdk-core/.eslintignore index 832e462b7a..7994a93d78 100644 --- a/packages/sdk-core/.eslintignore +++ b/packages/sdk-core/.eslintignore @@ -2,6 +2,6 @@ dist build coverage cache -src/typechain +src/typechain-types src/abi -**/*.generated.* +**/*.generated.* \ No newline at end of file diff --git a/packages/sdk-core/.gitignore b/packages/sdk-core/.gitignore index 1257b1f728..30b248b15f 100644 --- a/packages/sdk-core/.gitignore +++ b/packages/sdk-core/.gitignore @@ -5,4 +5,5 @@ coverage /src/typechain *.generated.ts /typechain-types -/artifacts \ No newline at end of file +/artifacts +src/typechain-types \ No newline at end of file diff --git a/packages/sdk-core/package.json b/packages/sdk-core/package.json index ca2731f146..3e298f284d 100644 --- a/packages/sdk-core/package.json +++ b/packages/sdk-core/package.json @@ -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", diff --git a/packages/sdk-core/src/ConstantFlowAgreementV1.ts b/packages/sdk-core/src/ConstantFlowAgreementV1.ts index 42ab030b3f..62260a7269 100644 --- a/packages/sdk-core/src/ConstantFlowAgreementV1.ts +++ b/packages/sdk-core/src/ConstantFlowAgreementV1.ts @@ -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"; @@ -28,6 +22,12 @@ import { IWeb3FlowOperatorData, IWeb3FlowOperatorDataParams, } from "./interfaces"; +import { + CFAv1Forwarder, + CFAv1Forwarder__factory, + IConstantFlowAgreementV1, + IConstantFlowAgreementV1__factory, +} from "./typechain-types"; import { getSanitizedTimestamp, isPermissionsClean, diff --git a/packages/sdk-core/src/ERC20Token.ts b/packages/sdk-core/src/ERC20Token.ts index 36374b1057..33a0974548 100644 --- a/packages/sdk-core/src/ERC20Token.ts +++ b/packages/sdk-core/src/ERC20Token.ts @@ -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 { diff --git a/packages/sdk-core/src/Framework.ts b/packages/sdk-core/src/Framework.ts index 3bf23efafb..2b47f18dc6 100644 --- a/packages/sdk-core/src/Framework.ts +++ b/packages/sdk-core/src/Framework.ts @@ -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"; @@ -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"; diff --git a/packages/sdk-core/src/Governance.ts b/packages/sdk-core/src/Governance.ts index 34f87c3dc5..6b561fbe36 100644 --- a/packages/sdk-core/src/Governance.ts +++ b/packages/sdk-core/src/Governance.ts @@ -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; diff --git a/packages/sdk-core/src/Host.ts b/packages/sdk-core/src/Host.ts index 5de4a863a7..e338fc0d73 100644 --- a/packages/sdk-core/src/Host.ts +++ b/packages/sdk-core/src/Host.ts @@ -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 diff --git a/packages/sdk-core/src/InstantDistributionAgreementV1.ts b/packages/sdk-core/src/InstantDistributionAgreementV1.ts index caf518c53a..58e046be9c 100644 --- a/packages/sdk-core/src/InstantDistributionAgreementV1.ts +++ b/packages/sdk-core/src/InstantDistributionAgreementV1.ts @@ -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"; @@ -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(); diff --git a/packages/sdk-core/src/Operation.ts b/packages/sdk-core/src/Operation.ts index f327584e1a..ca91f60140 100644 --- a/packages/sdk-core/src/Operation.ts +++ b/packages/sdk-core/src/Operation.ts @@ -1,4 +1,3 @@ -import { Superfluid__factory } from "@superfluid-finance/ethereum-contracts/build/typechain-ethers-v5"; import { ethers } from "ethers"; import { @@ -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 = diff --git a/packages/sdk-core/src/SuperToken.ts b/packages/sdk-core/src/SuperToken.ts index 7b3a38158c..0239e41c95 100644 --- a/packages/sdk-core/src/SuperToken.ts +++ b/packages/sdk-core/src/SuperToken.ts @@ -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"; @@ -48,6 +42,12 @@ import { SuperTokenFlowRateAllowanceParams, SuperTokenFlowRateAllowanceWithPermissionsParams, } from "./interfaces"; +import { + ISETH, + ISETH__factory, + ISuperToken, + ISuperToken__factory, +} from "./typechain-types"; import { getSanitizedTimestamp, getStringCurrentTimeInSeconds, diff --git a/packages/sdk-core/src/index.ts b/packages/sdk-core/src/index.ts index 85d755ba72..037dba5181 100644 --- a/packages/sdk-core/src/index.ts +++ b/packages/sdk-core/src/index.ts @@ -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 }; diff --git a/packages/sdk-core/src/interfaces.ts b/packages/sdk-core/src/interfaces.ts index dcb95e9570..7d337656f5 100644 --- a/packages/sdk-core/src/interfaces.ts +++ b/packages/sdk-core/src/interfaces.ts @@ -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 diff --git a/packages/sdk-core/tasks/build-types.sh b/packages/sdk-core/tasks/build-types.sh new file mode 100755 index 0000000000..f22129c155 --- /dev/null +++ b/packages/sdk-core/tasks/build-types.sh @@ -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 diff --git a/packages/sdk-core/test/2_operation.test.ts b/packages/sdk-core/test/2_operation.test.ts index b42a566c83..94d800ade2 100644 --- a/packages/sdk-core/test/2_operation.test.ts +++ b/packages/sdk-core/test/2_operation.test.ts @@ -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"; diff --git a/packages/sdk-core/test/TestEnvironment.ts b/packages/sdk-core/test/TestEnvironment.ts index 5d0c5e7aaf..a395442059 100644 --- a/packages/sdk-core/test/TestEnvironment.ts +++ b/packages/sdk-core/test/TestEnvironment.ts @@ -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, diff --git a/packages/ethereum-contracts/tsconfig.typechain.json b/packages/sdk-core/tsconfig.typechain.json similarity index 77% rename from packages/ethereum-contracts/tsconfig.typechain.json rename to packages/sdk-core/tsconfig.typechain.json index 93f4995eee..ac4d957a8a 100644 --- a/packages/ethereum-contracts/tsconfig.typechain.json +++ b/packages/sdk-core/tsconfig.typechain.json @@ -2,7 +2,7 @@ "extends": "./tsconfig", "compilerOptions": { "target": "ES2019", - "outDir": "build/typechain-ethers-v5", + "outDir": "src/typechain-types", "moduleResolution": "node", "module": "CommonJS", "declaration": true, @@ -10,6 +10,6 @@ "sourceMap": true }, "files": [], - "include": ["typechain-types"], + "include": ["src/typechain-types"], "exclude": ["node_modules/**"] -} +} \ No newline at end of file