Skip to content

Commit 181ccc6

Browse files
cgeweckerootulp
andauthored
Upgrade ethers to 5.4.6 / set-protocol-v2@0.1.0 (#76)
* Upgrade ethers to 5.4.6, set-protocol-v2 to 0.1.0 Co-authored-by: Rootul Patel <rootulp@gmail.com>
1 parent 0bc80e8 commit 181ccc6

14 files changed

+313
-958
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@
3939
"node": ">=10.16.0"
4040
},
4141
"devDependencies": {
42-
"@ethersproject/providers": "^5.0.18",
4342
"@types/node": "^14.0.23",
4443
"chai": "^4.2.0",
4544
"chai-as-promised": "^7.1.1",
4645
"chai-jest-mocks": "^1.2.4",
47-
"ganache-cli": "^6.9.1",
46+
"ganache-cli": "^6.12.2",
4847
"husky": "^4.2.5",
4948
"jest": "^26.1.0",
5049
"lint-staged": "^10.2.11",
@@ -53,13 +52,13 @@
5352
"tslint-eslint-rules": "^5.4.0",
5453
"typedoc": "^0.17.8",
5554
"typedoc-plugin-markdown": "^2.3.1",
56-
"typescript": "^3.9.7"
55+
"typescript": "^4.4.2"
5756
},
5857
"dependencies": {
5958
"@0xproject/types": "^1.1.4",
6059
"@0xproject/typescript-typings": "^3.0.2",
6160
"@0xproject/utils": "^2.0.2",
62-
"@setprotocol/set-protocol-v2": "0.0.31",
61+
"@setprotocol/set-protocol-v2": "^0.1.0",
6362
"@types/chai-as-promised": "^7.1.3",
6463
"@types/jest": "^26.0.5",
6564
"@types/web3": "^1.2.2",
@@ -69,7 +68,7 @@
6968
"dotenv": "^8.2.0",
7069
"ethereum-types": "^3.2.0",
7170
"ethereumjs-util": "^7.0.3",
72-
"ethers": "^5.0.3",
71+
"ethers": "5.4.6",
7372
"graph-results-pager": "^1.0.3",
7473
"js-big-decimal": "^1.3.4",
7574
"jsonschema": "^1.2.6",
@@ -112,7 +111,8 @@
112111
"js",
113112
"jsx",
114113
"json",
115-
"node"
114+
"node",
115+
"d.ts"
116116
],
117117
"moduleNameMapper": {
118118
"^@src/(.*)": "<rootDir>/src/$1",

src/api/DebtIssuanceAPI.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,13 @@ export default class DebtIssuanceAPI {
216216
quantity: BigNumber,
217217
isIssue: boolean,
218218
callerAddress: Address = undefined,
219-
): Promise<(BigNumber)[][]> {
219+
): Promise<
220+
[BigNumber, BigNumber, BigNumber] & {
221+
totalQuantity: BigNumber;
222+
managerFee: BigNumber;
223+
protocolFee: BigNumber;
224+
}
225+
> {
220226
this.assert.schema.isValidAddress('setAddress', setTokenAddress);
221227
this.assert.common.isNotUndefined(isIssue, 'isIssue arg must be a boolean.');
222228

src/api/ERC20API.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default class ERC20API {
120120
public async getDecimalsAsync(
121121
tokenAddress: Address,
122122
callerAddress: Address = undefined
123-
): Promise<BigNumber> {
123+
): Promise<number> {
124124
this.assert.schema.isValidAddress('tokenAddress', tokenAddress);
125125

126126
return this.erc20Wrapper.decimals(tokenAddress, callerAddress);

src/api/SetTokenAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default class SetTokenAPI {
8787
symbol: string,
8888
callerAddress: Address = undefined,
8989
txOpts: TransactionOverrides = {}
90-
): Promise<Address[]> {
90+
): Promise<ContractTransaction> {
9191
this.assert.common.isNotEmptyArray(componentAddresses, 'Component addresses must contain at least one component.');
9292
this.assert.common.isEqualLength(componentAddresses, units, 'Component addresses and units must be equal length.');
9393
this.assert.schema.isValidAddressList('componentAddresses', componentAddresses);

src/wrappers/set-protocol-v2/ContractWrapper.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ import {
2424
BasicIssuanceModule,
2525
DebtIssuanceModule,
2626
Controller,
27-
ERC20,
2827
ProtocolViewer,
2928
SetToken,
3029
SetTokenCreator,
3130
StreamingFeeModule,
3231
TradeModule,
3332
NavIssuanceModule,
3433
PriceOracle,
35-
} from '@setprotocol/set-protocol-v2/dist/utils/contracts';
34+
} from '@setprotocol/set-protocol-v2/typechain';
3635
import { BasicIssuanceModule__factory } from '@setprotocol/set-protocol-v2/dist/typechain/factories/BasicIssuanceModule__factory';
3736
import { DebtIssuanceModule__factory } from '@setprotocol/set-protocol-v2/dist/typechain/factories/DebtIssuanceModule__factory';
3837
import { Controller__factory } from '@setprotocol/set-protocol-v2/dist/typechain/factories/Controller__factory';
@@ -71,7 +70,7 @@ export default class ContractWrapper {
7170
public async loadControllerContractAsync(
7271
controllerAddress: Address,
7372
signer: Signer,
74-
): Controller {
73+
): Promise<Controller> {
7574
const cacheKey = `Controller_${controllerAddress}_${await signer.getAddress()}`;
7675

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

104103
if (cacheKey in this.cache) {
105-
return this.cache[cacheKey] as ERC20;
104+
return this.cache[cacheKey] as SetToken;
106105
} else {
107106
const tokenContract = ERC20__factory.connect(
108107
tokenAddress,
@@ -124,7 +123,7 @@ export default class ContractWrapper {
124123
public async loadBasicIssuanceModuleAsync(
125124
basicIssuanceModuleAddress: Address,
126125
callerAddress?: Address,
127-
): BasicIssuanceModule {
126+
): Promise<BasicIssuanceModule> {
128127
const signer = (this.provider as JsonRpcProvider).getSigner(callerAddress);
129128
const cacheKey = `BasicIssuance_${basicIssuanceModuleAddress}_${await signer.getAddress()}`;
130129

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

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

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

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

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

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

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

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

src/wrappers/set-protocol-v2/DebtIssuanceModuleWrapper.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@ export default class DebtIssuanceModuleWrapper {
222222
quantity: BigNumber,
223223
isIssue: boolean,
224224
callerAddress: Address = undefined,
225-
): Promise<(BigNumber)[][]> {
225+
): Promise<
226+
[BigNumber, BigNumber, BigNumber] & {
227+
totalQuantity: BigNumber;
228+
managerFee: BigNumber;
229+
protocolFee: BigNumber;
230+
}
231+
> {
226232
const debtIssuanceModuleInstance = await this.contracts.loadDebtIssuanceModuleAsync(
227233
this.debtIssuanceModuleAddress,
228234
callerAddress

src/wrappers/set-protocol-v2/ERC20Wrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export default class ERC20Wrapper {
128128
public async decimals(
129129
tokenAddress: Address,
130130
callerAddress: Address = undefined
131-
): Promise<BigNumber> {
131+
): Promise<number> {
132132
const tokenInstance = await this.contracts.loadERC20Async(
133133
tokenAddress,
134134
callerAddress

src/wrappers/set-protocol-v2/SetTokenCreatorWrapper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

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

@@ -64,7 +65,7 @@ export default class SetTokenCreatorWrapper {
6465
symbol: string,
6566
callerAddress?: Address,
6667
txOpts: TransactionOverrides = {}
67-
): Promise<Address[]> {
68+
): Promise<ContractTransaction> {
6869
const setTokenCreator = await this.contracts.loadSetTokenCreatorAsync(
6970
this.setTokenCreatorAddress,
7071
(this.provider as JsonRpcProvider).getSigner(callerAddress)

test/api/DebtIssuanceAPI.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,13 @@ describe('DebtIssuanceAPI', () => {
312312
subjectCallerAddress = '0x0e2298E3B3390e3b945a5456fBf59eCc3f55DA16';
313313
});
314314

315-
async function subject(): Promise<(Address|BigNumber)[][]> {
315+
async function subject(): Promise<
316+
[BigNumber, BigNumber, BigNumber] & {
317+
totalQuantity: BigNumber;
318+
managerFee: BigNumber;
319+
protocolFee: BigNumber;
320+
}
321+
> {
316322
return await debtIssuanceAPI.calculateTotalFeesAsync(
317323
subjectSetTokenAddress,
318324
subjectQuantity,

test/api/ERC20API.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ describe('ERC20API', () => {
188188
nullCallerAddress = '0x0000000000000000000000000000000000000000';
189189
});
190190

191-
async function subject(): Promise<BigNumber> {
191+
async function subject(): Promise<number> {
192192
return await erc20API.getDecimalsAsync(
193193
subjectTokenAddress,
194194
nullCallerAddress,

0 commit comments

Comments
 (0)