Skip to content

Commit

Permalink
Merge pull request #15 from lazaralex98/PRT-271-singerish-type-fix
Browse files Browse the repository at this point in the history
refactor: no need for address in constructor
  • Loading branch information
mauricedesaxe authored Jun 15, 2022
2 parents 42a741f + 30dff38 commit 079305a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Instantiate the Toucan client to interact with our infrastructure.
```typescript
import ToucanClient from "toucan-sdk";

const toucan = new ToucanClient("polygon", signer.address, provider, signer);
const toucan = new ToucanClient("polygon", provider, signer);
```

## Fetch pool prices from SushiSwap
Expand Down
14 changes: 5 additions & 9 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
IToucanPoolToken,
OffsetHelper,
} from "./typechain";
import { Network, poolSymbol, providerish, signerish } from "./types";
import { Network, poolSymbol } from "./types";
import {
fetchAggregationsMethod,
fetchAllTCO2TokensMethod,
Expand Down Expand Up @@ -44,9 +44,8 @@ import addresses, { IfcOneNetworksAddresses } from "./utils/addresses";
import { MUMBAI_GRAPH_API_URL, POLYGON_GRAPH_API_URL } from "./utils/graphAPIs";

class ToucanClient {
provider: providerish;
signer: signerish;
walletAddress: string;
provider: ethers.providers.Provider;
signer: ethers.Wallet | ethers.Signer;
network: Network;
addresses: IfcOneNetworksAddresses;
offsetHelper: OffsetHelper;
Expand All @@ -59,18 +58,15 @@ class ToucanClient {
/**
*
* @param network network that you want to work on
* @param walletAddress address of the signer you want to use
* @param provider web3 or jsonRpc provider
* @param signer signer
*/
constructor(
network: Network,
walletAddress: string,
provider: providerish,
signer: signerish
provider: ethers.providers.Provider,
signer: ethers.Wallet | ethers.Signer
) {
this.network = network;
this.walletAddress = walletAddress;
this.provider = provider;
this.signer = signer;

Expand Down
9 changes: 2 additions & 7 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Testing Toucan-SDK", function () {

before(async () => {
[addr1, addr2, ...addrs] = await ethers.getSigners();
toucan = new ToucanClient("polygon", addr1.address, ethers.provider, addr1);
toucan = new ToucanClient("polygon", ethers.provider, addr1);

swapper = new ethers.Contract(addresses.polygon.swapper, swapperABI, addr1);
await swapper.swap(addresses.polygon.nct, parseEther("100.0"), {
Expand Down Expand Up @@ -260,12 +260,7 @@ describe("Testing Toucan-SDK", function () {
toucan.instantiateTCO2(tco2s[0].address);
await toucan.TCO2?.approve(addr2.address, parseEther("1.0"));

const toucan2 = new ToucanClient(
"polygon",
addr2.address,
ethers.provider,
addr2
);
const toucan2 = new ToucanClient("polygon", ethers.provider, addr2);
toucan2.instantiateTCO2(tco2s[0].address);
await expect(toucan2.retireFrom(parseEther("1.0"), addr1.address)).to.not
.be.reverted;
Expand Down
8 changes: 0 additions & 8 deletions types/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { ethers } from "ethers";

export type Network = "polygon" | "mumbai";

export type providerish =
| ethers.providers.Web3Provider
| ethers.providers.JsonRpcProvider;

export type signerish = ethers.providers.Provider | ethers.Signer;

export type poolSymbol = "BCT" | "NCT";

export declare enum RetirementStatus {
Expand Down

0 comments on commit 079305a

Please sign in to comment.