Skip to content

Commit

Permalink
refactor: replace old typechain artifacts with imported
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmichalis committed Feb 17, 2025
1 parent 94b1820 commit 81bee00
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 2,333 deletions.
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import { FormatTypes, Interface } from "ethers/lib/utils";

import ContractInteractions from "./subclasses/ContractInteractions";
import SubgraphInteractions from "./subclasses/SubgraphInteractions";
import { IToucanPoolToken } from "./typechain/legacy";
import {
IToucanCarbonOffsets,
IToucanContractRegistry,
IToucanPoolToken,
OffsetHelper,
} from "./typechain/misc";
import {
ToucanCarbonOffsets,
ToucanContractRegistry,
} from "./typechain/protocol";
import { Network, PoolSymbol } from "./types";
import {
AggregationsMethod,
Expand Down Expand Up @@ -878,7 +880,7 @@ export default class ToucanClient {
* @param address address of TCO2 ethers.Contract to insantiate
* @returns a ethers.contract to interact with the token
*/
getTCO2Contract = (address: string): IToucanCarbonOffsets => {
getTCO2Contract = (address: string): ToucanCarbonOffsets => {
const signerOrProvider = this.signer ? this.signer : this.provider;
if (!signerOrProvider) throw new Error("No signer or provider set");

Expand All @@ -890,7 +892,7 @@ export default class ToucanClient {
* @description gets the contract of a the Toucan contract registry
* @returns a ethers.contract to interact with the contract registry
*/
public getRegistryContract = (): IToucanContractRegistry => {
public getRegistryContract = (): ToucanContractRegistry => {
const signerOrProvider = this.signer ? this.signer : this.provider;
if (!signerOrProvider) throw new Error("No signer or provider set");

Expand Down
16 changes: 9 additions & 7 deletions src/subclasses/ContractInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import {
ethers,
} from "ethers";

import { IToucanPoolToken } from "../typechain/legacy";
import {
IToucanCarbonOffsets,
IToucanContractRegistry,
IToucanPoolToken,
OffsetHelper,
} from "../typechain/misc";
import {
ToucanCarbonOffsets,
ToucanContractRegistry,
} from "../typechain/protocol";
import { Network, PoolSymbol } from "../types";
import { RedeemAutoResponse } from "../types/responses";
import { GAS_LIMIT } from "../utils";
Expand Down Expand Up @@ -729,15 +731,15 @@ class ContractInteractions {
getTCO2Contract = (
address: string,
signerOrProvider: ethers.Signer | ethers.providers.Provider
): IToucanCarbonOffsets => {
): ToucanCarbonOffsets => {
if (!this.checkIfTCO2(address, signerOrProvider))
throw new Error(`${address} is not a TCO2 address`);

const TCO2 = new ethers.Contract(
address,
tco2ABI,
signerOrProvider
) as IToucanCarbonOffsets;
) as ToucanCarbonOffsets;
return TCO2;
};

Expand All @@ -749,12 +751,12 @@ class ContractInteractions {
*/
public getRegistryContract = (
signerOrProvider: ethers.Signer | ethers.providers.Provider
): IToucanContractRegistry => {
): ToucanContractRegistry => {
const toucanContractRegistry = new ethers.Contract(
this.addresses.toucanContractRegistry,
toucanContractRegistryABI,
signerOrProvider
) as IToucanContractRegistry;
) as ToucanContractRegistry;
return toucanContractRegistry;
};

Expand Down
4 changes: 2 additions & 2 deletions src/subclasses/SubgraphInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { Client, gql } from "@urql/core";

import { IToucanCarbonOffsets } from "../typechain/misc";
import { ToucanCarbonOffsets } from "../typechain/protocol";
import { Network, PoolSymbol } from "../types";
import {
AggregationsMethod,
Expand Down Expand Up @@ -49,7 +49,7 @@ import { getDexGraphClient, getToucanGraphClient } from "../utils/graphClients";
class SubgraphInteractions {
network: Network;
addresses: INetworkTokenAddresses;
TCO2: IToucanCarbonOffsets | undefined;
TCO2: ToucanCarbonOffsets | undefined;
graphClient: Client;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { BytesLike } from "@ethersproject/bytes";
import { Listener, Provider } from "@ethersproject/providers";
import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi";
import type { TypedEventFilter, TypedEvent, TypedListener } from "./common";
import type { TypedEventFilter, TypedEvent, TypedListener } from "../misc/common";

interface IToucanPoolTokenInterface extends ethers.utils.Interface {
functions: {
Expand Down
5 changes: 5 additions & 0 deletions src/typechain/legacy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */

export type { IToucanPoolToken } from "./IToucanPoolToken";
Loading

0 comments on commit 81bee00

Please sign in to comment.