Skip to content

Commit

Permalink
[ETHEREUM-CONTRACTS/SDK-CORE/SUBGRAPH] Use more Typechain capabilities (
Browse files Browse the repository at this point in the history
#1113)

Provide end-consumer access to typechain files via ethereum-contracts as the origin source and also exported via sdk-core
no more abi file imports, using typechain generated factories all around
fix up lint scripts
add typechain build pipeline in ethereum-contracts
Co-authored-by: Daniel <tokdaniel4@gmail.com>
  • Loading branch information
0xdavinchee authored Oct 12, 2022
1 parent eef6e1f commit 5713860
Show file tree
Hide file tree
Showing 43 changed files with 264 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: "Build contracts"
run: |
yarn build:contracts-truffle
yarn build:contracts-hardhat
run: yarn build
working-directory: ./packages/ethereum-contracts

- name: "Start hardhat node"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: "Build contracts"
run: |
yarn build:contracts-truffle
yarn build:contracts-hardhat
run: yarn build
working-directory: ./packages/ethereum-contracts

- name: "Start hardhat node"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/call.test-sdk-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: "Build contracts"
run: |
yarn build:contracts-truffle
yarn build:contracts-hardhat
run: yarn build
working-directory: ./packages/ethereum-contracts

- name: "Run test suite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: "Build contracts"
run: |
yarn build:contracts-truffle
yarn build:contracts-hardhat
run: yarn build
working-directory: ${{ env.contracts-working-directory }}

- name: "Start hardhat node"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/handler.deploy-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: "Build contracts"
run: |
yarn build:contracts-truffle
yarn build:contracts-hardhat
run: yarn build
working-directory: ${{ env.contracts-working-directory }}

- name: "Get ABI"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"truffle": "^5.5.28",
"ts-node": "^10.8.2",
"typechain": "^8.1.0",
"typedoc": "^0.23.12",
"typedoc": "^0.23.15",
"typescript": "^4.7.4",
"web3": "^1.7.5"
},
Expand Down
11 changes: 11 additions & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

### Added

- CFA Hooks added (#1099)
- typechain types are provided to all consumers (#1113)
- `SuperfluidFrameworkDeployer.sol` create Native Asset and Pure Super Tokens functionality added (#1104)
- `TestResolver` added to allow `SuperfluidFrameworkDeployer` contract to grant admin permissions to its deployer (#1104)

### Fixes

- CFA Agreement forwarder delete flow fix to allow receivers to delete flow (#1094)

## [v.1.4.1] - 2022-09-20

### Added
Expand Down
7 changes: 5 additions & 2 deletions packages/ethereum-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"/build/contracts-sizes.txt",
"/build/abi.js",
"scripts/**/*",
"utils/**/*"
"utils/**/*",
"/build/typechain/**/*"
],
"scripts": {
"dev": "tasks/dev.sh",
Expand All @@ -32,6 +33,7 @@
"build:contracts": "rm -f build/contracts/*;yarn build:contracts-truffle",
"build:contracts-truffle": "yarn run-truffle compile",
"build:contracts-hardhat": "yarn run-hardhat compile",
"build:typechain": "tsc -p tsconfig.typechain.json",
"build:contracts-size": "tasks/print-contract-sizes.sh | tee build/contracts-sizes.txt",
"testenv:start": "test/testenv-ctl.sh start",
"testenv:stop": "test/testenv-ctl.sh stop",
Expand All @@ -48,7 +50,8 @@
"posttest": "yarn testenv:stop",
"lint": "run-s lint:*",
"lint:sol": "solhint -w 0 contracts/*.sol contracts/*/*.sol && echo '✔ Your .sol files look good.'",
"lint:js-eslint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
"lint-js": "eslint test -c .eslintrc.json --ext .js",
"lint:js-eslint": "yarn lint-js --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
"lint-ts": "eslint test -c .eslintrc.ts.json --ext .ts",
"lint:ts-eslint": "yarn lint-ts --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .ts files look good.'",
"fix": "run-s fix:*",
Expand Down
10 changes: 7 additions & 3 deletions packages/ethereum-contracts/test/TestEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {artifacts, assert, ethers, expect, network, web3} from "hardhat";
import _ from "lodash";
import Web3 from "web3";

import {ISuperToken, SuperTokenMock, TestToken} from "../typechain-types";
import {
ISuperToken,
ISuperToken__factory,
SuperTokenMock,
TestToken,
} from "../typechain-types";

import {VerifyOptions} from "./contracts/agreements/Agreement.types";
import AgreementHelper from "./contracts/agreements/AgreementHelper";
Expand All @@ -27,7 +32,6 @@ const {web3tx, wad4human} = require("@decentral.ee/web3-helpers");
const SuperfluidSDK = require("@superfluid-finance/js-sdk");
const traveler = require("ganache-time-traveler");

const ISuperTokenArtifact = require("../artifacts/contracts/interfaces/superfluid/ISuperToken.sol/ISuperToken.json");
const deployFramework = require("../scripts/deploy-framework");
const deploySuperToken = require("../scripts/deploy-super-token");
const deployTestToken = require("../scripts/deploy-test-token");
Expand Down Expand Up @@ -292,7 +296,7 @@ export default class TestEnvironment {
)),
(this.contracts.ISuperToken = new ethers.Contract(
"ISuperToken",
ISuperTokenArtifact.abi,
ISuperToken__factory.abi,
signer
) as ISuperToken),
(this.contracts.resolver = await ethers.getContractAt(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {artifacts, assert, ethers, expect, web3} from "hardhat";

import SuperTokenArtifact from "../../../artifacts/contracts/superfluid/SuperToken.sol/SuperToken.json";
import {
CustomSuperTokenMock,
MockSmartWallet,
SuperfluidMock,
SuperToken,
SuperToken__factory,
SuperTokenMock,
TestToken,
} from "../../../typechain-types";
Expand Down Expand Up @@ -46,7 +46,7 @@ describe("SuperToken's Non Standard Functions", function () {
bobSigner = await ethers.getSigner(bob);
superTokenContract = new ethers.Contract(
"SuperToken",
SuperTokenArtifact.abi,
SuperToken__factory.abi,
aliceSigner
) as SuperToken;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {assert} from "chai";
import {artifacts, ethers, web3} from "hardhat";

import SuperTokenArtifact from "../../../artifacts/contracts/superfluid/SuperToken.sol/SuperToken.json";
import {ISETH} from "../../../typechain-types";
import {ISETH, SuperToken__factory} from "../../../typechain-types";
import TestEnvironment from "../../TestEnvironment";
import {expectCustomError} from "../../utils/expectRevert";

Expand Down Expand Up @@ -119,7 +118,7 @@ describe("Super ETH (SETH) Contract", function () {
});
const superTokenContract = new ethers.Contract(
"SuperToken",
SuperTokenArtifact.abi,
SuperToken__factory.abi,
aliceSigner
);
await expectCustomError(
Expand Down
15 changes: 15 additions & 0 deletions packages/ethereum-contracts/tsconfig.typechain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"target": "ES2019",
"outDir": "build/typechain",
"moduleResolution": "node",
"module": "CommonJS",
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"files": [],
"include": ["typechain-types"],
"exclude": ["node_modules/**"]
}
10 changes: 10 additions & 0 deletions packages/sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Breaking

- Creating `BatchCall` class directly requires `providerOrSigner` property now
- Migration: pass a signer or provider object for `providerOrSigner` if creating `BatchCall` class directly
> NOTE: This does not impact you if you are creating `BatchCall`'s via the `Framework` class
### Added

- typechain files consumed from `@superfluid-finance/ethereum-contracts` and exported from SDK-Core

## [0.5.6] - 2022-09-07
### Fixes
- Correct `subgraphAPIEndpoint` in `getResolverData`
Expand Down
8 changes: 3 additions & 5 deletions packages/sdk-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"testenv:stop": "tasks/testenv-ctl.sh stop",
"pretest": "yarn testenv:start",
"test": "hardhat test --network localhost --tsconfig \"tsconfig.test.json\"",
"dev": "nodemon -e ts -i src/typechain -x hardhat test --network localhost --tsconfig \"tsconfig.test.json\"",
"dev": "nodemon -e ts -x hardhat test --network localhost --tsconfig \"tsconfig.test.json\"",
"test-coverage": "nyc --reporter=html --reporter=lcov --reporter=json yarn test",
"posttest": "yarn testenv:stop",
"check-updates": "ncu --target minor --dep prod,dev",
"doc:html": "typedoc --out dist/docs --entryPoints ./src/index.ts && copyfiles -f ./sf-logo.png ./dist/docs/",
"doc:html": "typedoc --entryPointStrategy expand ./src --options ./typedoc.js && copyfiles -f ./sf-logo.png ./dist/docs/",
"lint": "run-s lint:*",
"lint:eslint": "eslint src --ext .ts",
"fix": "run-s fix:*",
Expand All @@ -42,8 +42,6 @@
"set-default-subgraph-release-tag": "node scripts/setDefaultSubgraphReleaseTag.js",
"start-node": "hardhat node",
"generate": "run-s generate:*",
"generate:abi-files": "rm -rf src/abi && mkdir -p src/abi && tasks/build-abi-json.sh",
"generate:web3-types": "typechain --target=ethers-v5 --out-dir=./src/typechain \"./src/abi/**/*.json\"",
"generate:ajv-validations": "ts-node scripts/ajv.ts",
"generate:graphql-types": "graphql-codegen --config subgraph-codegen.yml",
"generate-graphql-schema": "yarn generate-graphql-schema:v1",
Expand All @@ -57,6 +55,7 @@
"url": "https://github.com/superfluid-finance/protocol-monorepo/issues"
},
"dependencies": {
"@superfluid-finance/ethereum-contracts": "1.4.1",
"@superfluid-finance/metadata": "git+https://github.com/superfluid-finance/metadata.git",
"browserify": "^17.0.0",
"graphql-request": "^4.3.0",
Expand All @@ -71,7 +70,6 @@
"@graphql-codegen/typescript": "^2.7.3",
"@graphql-codegen/typescript-operations": "^2.5.3",
"@graphql-typed-document-node/core": "^3.1.1",
"@superfluid-finance/ethereum-contracts": "1.4.1",
"ajv": "^8.11.0",
"get-graphql-schema": "^2.1.2",
"mocha": "^10.0.0"
Expand Down
7 changes: 4 additions & 3 deletions packages/sdk-core/src/BatchCall.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { JsonFragment } from "@ethersproject/abi";
import { Superfluid__factory } from "@superfluid-finance/ethereum-contracts/build/typechain";
import { ethers } from "ethers";

import Host from "./Host";
import Operation, { OperationType } from "./Operation";
import { SFError } from "./SFError";
import SuperfluidABI from "./abi/Superfluid.json";
import { getTransactionDescription, removeSigHashFromCallData } from "./utils";

interface IBatchCallOptions {
hostAddress: string;
operations: ReadonlyArray<Operation>;
providerOrSigner: ethers.providers.Provider | ethers.Signer;
}

interface OperationStruct {
Expand Down Expand Up @@ -85,7 +86,7 @@ export default class BatchCall {
// Handles Superfluid.callAgreement
if (operation.type === "SUPERFLUID_CALL_AGREEMENT") {
const functionArgs = this.getCallDataFunctionArgs(
SuperfluidABI.abi,
Superfluid__factory.abi,
populatedTransaction.data
);
const data = encoder.encode(
Expand All @@ -103,7 +104,7 @@ export default class BatchCall {
// Handles Superfluid.callAppAction
if (operation.type === "CALL_APP_ACTION") {
const functionArgs = this.getCallDataFunctionArgs(
SuperfluidABI.abi,
Superfluid__factory.abi,
populatedTransaction.data
);

Expand Down
Loading

0 comments on commit 5713860

Please sign in to comment.