Skip to content

Commit

Permalink
Upgrade ethers to 5.4.6 / set-protocol-v2@0.1.0 (#76)
Browse files Browse the repository at this point in the history
* Upgrade ethers to 5.4.6, set-protocol-v2 to 0.1.0

Co-authored-by: Rootul Patel <rootulp@gmail.com>
  • Loading branch information
cgewecke and rootulp authored Sep 15, 2021
1 parent 0bc80e8 commit 181ccc6
Show file tree
Hide file tree
Showing 14 changed files with 313 additions and 958 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@
"node": ">=10.16.0"
},
"devDependencies": {
"@ethersproject/providers": "^5.0.18",
"@types/node": "^14.0.23",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-jest-mocks": "^1.2.4",
"ganache-cli": "^6.9.1",
"ganache-cli": "^6.12.2",
"husky": "^4.2.5",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
Expand All @@ -53,13 +52,13 @@
"tslint-eslint-rules": "^5.4.0",
"typedoc": "^0.17.8",
"typedoc-plugin-markdown": "^2.3.1",
"typescript": "^3.9.7"
"typescript": "^4.4.2"
},
"dependencies": {
"@0xproject/types": "^1.1.4",
"@0xproject/typescript-typings": "^3.0.2",
"@0xproject/utils": "^2.0.2",
"@setprotocol/set-protocol-v2": "0.0.31",
"@setprotocol/set-protocol-v2": "^0.1.0",
"@types/chai-as-promised": "^7.1.3",
"@types/jest": "^26.0.5",
"@types/web3": "^1.2.2",
Expand All @@ -69,7 +68,7 @@
"dotenv": "^8.2.0",
"ethereum-types": "^3.2.0",
"ethereumjs-util": "^7.0.3",
"ethers": "^5.0.3",
"ethers": "5.4.6",
"graph-results-pager": "^1.0.3",
"js-big-decimal": "^1.3.4",
"jsonschema": "^1.2.6",
Expand Down Expand Up @@ -112,7 +111,8 @@
"js",
"jsx",
"json",
"node"
"node",
"d.ts"
],
"moduleNameMapper": {
"^@src/(.*)": "<rootDir>/src/$1",
Expand Down
8 changes: 7 additions & 1 deletion src/api/DebtIssuanceAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ export default class DebtIssuanceAPI {
quantity: BigNumber,
isIssue: boolean,
callerAddress: Address = undefined,
): Promise<(BigNumber)[][]> {
): Promise<
[BigNumber, BigNumber, BigNumber] & {
totalQuantity: BigNumber;
managerFee: BigNumber;
protocolFee: BigNumber;
}
> {
this.assert.schema.isValidAddress('setAddress', setTokenAddress);
this.assert.common.isNotUndefined(isIssue, 'isIssue arg must be a boolean.');

Expand Down
2 changes: 1 addition & 1 deletion src/api/ERC20API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class ERC20API {
public async getDecimalsAsync(
tokenAddress: Address,
callerAddress: Address = undefined
): Promise<BigNumber> {
): Promise<number> {
this.assert.schema.isValidAddress('tokenAddress', tokenAddress);

return this.erc20Wrapper.decimals(tokenAddress, callerAddress);
Expand Down
2 changes: 1 addition & 1 deletion src/api/SetTokenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class SetTokenAPI {
symbol: string,
callerAddress: Address = undefined,
txOpts: TransactionOverrides = {}
): Promise<Address[]> {
): Promise<ContractTransaction> {
this.assert.common.isNotEmptyArray(componentAddresses, 'Component addresses must contain at least one component.');
this.assert.common.isEqualLength(componentAddresses, units, 'Component addresses and units must be equal length.');
this.assert.schema.isValidAddressList('componentAddresses', componentAddresses);
Expand Down
27 changes: 13 additions & 14 deletions src/wrappers/set-protocol-v2/ContractWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ import {
BasicIssuanceModule,
DebtIssuanceModule,
Controller,
ERC20,
ProtocolViewer,
SetToken,
SetTokenCreator,
StreamingFeeModule,
TradeModule,
NavIssuanceModule,
PriceOracle,
} from '@setprotocol/set-protocol-v2/dist/utils/contracts';
} from '@setprotocol/set-protocol-v2/typechain';
import { BasicIssuanceModule__factory } from '@setprotocol/set-protocol-v2/dist/typechain/factories/BasicIssuanceModule__factory';
import { DebtIssuanceModule__factory } from '@setprotocol/set-protocol-v2/dist/typechain/factories/DebtIssuanceModule__factory';
import { Controller__factory } from '@setprotocol/set-protocol-v2/dist/typechain/factories/Controller__factory';
Expand Down Expand Up @@ -71,7 +70,7 @@ export default class ContractWrapper {
public async loadControllerContractAsync(
controllerAddress: Address,
signer: Signer,
): Controller {
): Promise<Controller> {
const cacheKey = `Controller_${controllerAddress}_${await signer.getAddress()}`;

if (cacheKey in this.cache) {
Expand All @@ -97,12 +96,12 @@ export default class ContractWrapper {
public async loadERC20Async(
tokenAddress: Address,
callerAddress?: Address,
): SetToken {
): Promise<SetToken> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `ERC20_${tokenAddress}_${await signer.getAddress()}`;

if (cacheKey in this.cache) {
return this.cache[cacheKey] as ERC20;
return this.cache[cacheKey] as SetToken;
} else {
const tokenContract = ERC20__factory.connect(
tokenAddress,
Expand All @@ -124,7 +123,7 @@ export default class ContractWrapper {
public async loadBasicIssuanceModuleAsync(
basicIssuanceModuleAddress: Address,
callerAddress?: Address,
): BasicIssuanceModule {
): Promise<BasicIssuanceModule> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `BasicIssuance_${basicIssuanceModuleAddress}_${await signer.getAddress()}`;

Expand All @@ -151,7 +150,7 @@ export default class ContractWrapper {
public async loadTradeModuleAsync(
tradeModuleAddress: Address,
callerAddress?: Address,
): TradeModule {
): Promise<TradeModule> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `TradeModule_${tradeModuleAddress}_${await signer.getAddress()}`;

Expand Down Expand Up @@ -188,7 +187,7 @@ export default class ContractWrapper {
public async loadNavIssuanceModuleAsync(
navIssuanceModuleAddress: Address,
callerAddress?: Address,
): NavIssuanceModule {
): Promise<NavIssuanceModule> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `NavIssuanceModule_${navIssuanceModuleAddress}_${await signer.getAddress()}`;

Expand All @@ -215,7 +214,7 @@ export default class ContractWrapper {
public async loadMasterPriceOracleAsync(
masterOracleAddress: Address,
callerAddress?: Address,
): PriceOracle {
): Promise<PriceOracle> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `MasterPriceOracle_${masterOracleAddress}_${await signer.getAddress()}`;

Expand All @@ -242,7 +241,7 @@ export default class ContractWrapper {
public async loadSetTokenAsync(
setTokenAddress: Address,
callerAddress?: Address,
): SetToken {
): Promise<SetToken> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `SetToken_${setTokenAddress}_${await signer.getAddress()}`;

Expand All @@ -269,7 +268,7 @@ export default class ContractWrapper {
public async loadSetTokenCreatorAsync(
setTokenCreatorAddress: Address,
signer: Signer,
): SetTokenCreator {
): Promise<SetTokenCreator> {
const cacheKey = `SetTokenCreator_${setTokenCreatorAddress}_${await signer.getAddress()}`;

if (cacheKey in this.cache) {
Expand All @@ -295,7 +294,7 @@ export default class ContractWrapper {
public async loadStreamingFeeModuleAsync(
streamingFeeModuleAddress: Address,
callerAddress?: Address,
): StreamingFeeModule {
): Promise<StreamingFeeModule> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `StreamingFeeModule_${streamingFeeModuleAddress}_${await signer.getAddress()}`;

Expand All @@ -322,7 +321,7 @@ export default class ContractWrapper {
public async loadProtocolViewerContractAsync(
protocolViewerAddress: Address,
signer: Signer,
): ProtocolViewer {
): Promise<ProtocolViewer> {
const cacheKey = `ProtocolViewer_${protocolViewerAddress}_${await signer.getAddress()}`;

if (cacheKey in this.cache) {
Expand All @@ -349,7 +348,7 @@ export default class ContractWrapper {
public async loadDebtIssuanceModuleAsync(
debtIssuanceModuleAddress: Address,
callerAddress?: Address,
): DebtIssuanceModule {
): Promise<DebtIssuanceModule> {
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
const cacheKey = `DebtIssuanceModule_${debtIssuanceModuleAddress}_${await signer.getAddress()}`;

Expand Down
8 changes: 7 additions & 1 deletion src/wrappers/set-protocol-v2/DebtIssuanceModuleWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ export default class DebtIssuanceModuleWrapper {
quantity: BigNumber,
isIssue: boolean,
callerAddress: Address = undefined,
): Promise<(BigNumber)[][]> {
): Promise<
[BigNumber, BigNumber, BigNumber] & {
totalQuantity: BigNumber;
managerFee: BigNumber;
protocolFee: BigNumber;
}
> {
const debtIssuanceModuleInstance = await this.contracts.loadDebtIssuanceModuleAsync(
this.debtIssuanceModuleAddress,
callerAddress
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/set-protocol-v2/ERC20Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class ERC20Wrapper {
public async decimals(
tokenAddress: Address,
callerAddress: Address = undefined
): Promise<BigNumber> {
): Promise<number> {
const tokenInstance = await this.contracts.loadERC20Async(
tokenAddress,
callerAddress
Expand Down
3 changes: 2 additions & 1 deletion src/wrappers/set-protocol-v2/SetTokenCreatorWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { Provider, JsonRpcProvider } from '@ethersproject/providers';
import { BigNumber } from 'ethers/lib/ethers';
import { ContractTransaction } from 'ethers';
import { Address } from '@setprotocol/set-protocol-v2/utils/types';
import { TransactionOverrides } from '@setprotocol/set-protocol-v2/dist/typechain';

Expand Down Expand Up @@ -64,7 +65,7 @@ export default class SetTokenCreatorWrapper {
symbol: string,
callerAddress?: Address,
txOpts: TransactionOverrides = {}
): Promise<Address[]> {
): Promise<ContractTransaction> {
const setTokenCreator = await this.contracts.loadSetTokenCreatorAsync(
this.setTokenCreatorAddress,
(this.provider as JsonRpcProvider).getSigner(callerAddress)
Expand Down
8 changes: 7 additions & 1 deletion test/api/DebtIssuanceAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,13 @@ describe('DebtIssuanceAPI', () => {
subjectCallerAddress = '0x0e2298E3B3390e3b945a5456fBf59eCc3f55DA16';
});

async function subject(): Promise<(Address|BigNumber)[][]> {
async function subject(): Promise<
[BigNumber, BigNumber, BigNumber] & {
totalQuantity: BigNumber;
managerFee: BigNumber;
protocolFee: BigNumber;
}
> {
return await debtIssuanceAPI.calculateTotalFeesAsync(
subjectSetTokenAddress,
subjectQuantity,
Expand Down
2 changes: 1 addition & 1 deletion test/api/ERC20API.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('ERC20API', () => {
nullCallerAddress = '0x0000000000000000000000000000000000000000';
});

async function subject(): Promise<BigNumber> {
async function subject(): Promise<number> {
return await erc20API.getDecimalsAsync(
subjectTokenAddress,
nullCallerAddress,
Expand Down
2 changes: 1 addition & 1 deletion test/api/SetTokenAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('SetTokenAPI', () => {
subjectTransactionOptions = {};
});

async function subject(): Promise<Address[]> {
async function subject(): Promise<ContractTransaction> {
return await setTokenAPI.createAsync(
subjectComponentAddresses,
subjectUnits,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,13 @@ describe('DebtIssuanceModuleWrapper', () => {
subjectCaller = functionCaller;
});

async function subject(): Promise<(BigNumber)[][]> {
async function subject(): Promise<
[BigNumber, BigNumber, BigNumber] & {
totalQuantity: BigNumber;
managerFee: BigNumber;
protocolFee: BigNumber;
}
> {
await debtIssuanceModule.initialize(
subjectSetTokenAddress,
subjectMaxManagerFee,
Expand Down
6 changes: 3 additions & 3 deletions test/wrappers/set-protocol-v2/ERC20Wrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('ERC20Wrapper', () => {
const tokenSupply: BigNumber = ether(1000000000);
const tokenName: string = 'Token';
const tokenSymbol: string = 'Symbol';
const tokenDecimals: BigNumber = BigNumber.from(18);
const tokenDecimals: number = 18;

let subjectTokenAddress: Address;

Expand All @@ -71,7 +71,7 @@ describe('ERC20Wrapper', () => {
name: string,
symbol: string,
supply: BigNumber,
decimals: BigNumber,
decimals: number,
}> {
const name = await erc20Wrapper.name(subjectTokenAddress);
const symbol = await erc20Wrapper.symbol(subjectTokenAddress);
Expand All @@ -87,7 +87,7 @@ describe('ERC20Wrapper', () => {
expect(name).to.eql(tokenName);
expect(symbol).to.eql(tokenSymbol);
expect(supply.toString()).to.eql(tokenSupply.toString());
expect(decimals.toString()).to.eql(tokenDecimals.toString());
expect(decimals).to.eql(tokenDecimals);
});
});

Expand Down
Loading

0 comments on commit 181ccc6

Please sign in to comment.