Skip to content

Commit

Permalink
fix: augment version types
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanie committed Jun 20, 2024
1 parent 8b10de0 commit 587fb30
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 128 deletions.
61 changes: 7 additions & 54 deletions packages/colony-js/src/clients/Core/ColonyClientV10.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,26 @@
import type { SignerOrProvider } from '@colony/core';

import { IColony__factory as IColonyFactory } from '../../contracts/IColony/10/factories/IColony__factory.js';
import { IColony } from '../../contracts/IColony/10/IColony.js';
import { ColonyNetworkClient } from '../ColonyNetworkClient.js';
import {
AugmentedIColony,
AugmentedEstimate,
} from './augments/commonAugments.js';
import { ColonyAugmentsV3 } from './augments/augmentsV3.js';
import { ColonyAugmentsV4 } from './augments/augmentsV4.js';
import { ColonyAugmentsV5 } from './augments/augmentsV5.js';
import { ColonyAugmentsV6 } from './augments/augmentsV6.js';
import {
addAugments,
ColonyAugmentsV7,
AugmentedEstimateV7,
} from './augments/augmentsV7.js';
import {
AddDomainAugmentsB,
AddDomainEstimateGasB,
addAugmentsB as addAddDomainAugments,
} from './augments/AddDomain.js';
import {
MoveFundsBetweenPotsAugmentsB,
MoveFundsBetweenPotsEstimateGasB,
addAugmentsB as addMoveFundsBetweenPotsAugments,
} from './augments/MoveFundsBetweenPots.js';

interface ColonyClientV10Estimate
extends AugmentedEstimate<IColony>,
AugmentedEstimateV7,
AddDomainEstimateGasB,
MoveFundsBetweenPotsEstimateGasB {}

export interface ColonyClientV10
extends AugmentedIColony<IColony>,
ColonyAugmentsV3<IColony>,
ColonyAugmentsV4<IColony>,
ColonyAugmentsV5<IColony>,
ColonyAugmentsV6<IColony>,
ColonyAugmentsV7<IColony>,
AddDomainAugmentsB<IColony>,
MoveFundsBetweenPotsAugmentsB<IColony> {
clientVersion: 10;
estimateGas: ColonyClientV10Estimate;

// This is only to hide certain internal ethers.js properties from the docs
/** @internal */
callStatic: IColony['callStatic'];
/** @internal */
functions: IColony['functions'];
/** @internal */
populateTransaction: IColony['populateTransaction'];
}
import { UnknownIColonyClient } from './augments/commonAugments.js';
import { addAugments } from './augments/augmentsV7.js';
import { addAugmentsB as addAddDomainAugments } from './augments/AddDomain.js';
import { addAugmentsB as addMoveFundsBetweenPotsAugments } from './augments/MoveFundsBetweenPots.js';

export default function getColonyClient(
this: ColonyNetworkClient,
address: string,
signerOrProvider: SignerOrProvider,
): ColonyClientV10 {
) {
const colonyClient = IColonyFactory.connect(
address,
signerOrProvider,
) as ColonyClientV10;
) as UnknownIColonyClient;

colonyClient.clientVersion = 10;
addAugments(colonyClient, this);
addAddDomainAugments(colonyClient);
addMoveFundsBetweenPotsAugments(colonyClient);

return colonyClient as ColonyClientV10;
return colonyClient;
}
10 changes: 2 additions & 8 deletions packages/colony-js/src/clients/Core/augments/AddDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {

import {
IColonyV4,
IColonyV10,
IColonyV11,
IColonyV12,
IColonyV13,
IColonyV14,
IColonyV15,
} from '../contracts.js';
import type {
AugmentedIColony,
Expand All @@ -22,12 +21,7 @@ import type {
type ValidColonyA = IColonyV4;

// Colonies that support the later (overloaded) methods
type ValidColonyB =
| IColonyV10
| IColonyV11
| IColonyV12
| IColonyV13
| IColonyV14;
type ValidColonyB = IColonyV12 | IColonyV13 | IColonyV14 | IColonyV15;

export interface AddDomainEstimateGasA {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,18 @@ import {

import {
IColonyV6,
IColonyV10,
IColonyV11,
IColonyV12,
IColonyV13,
IColonyV14,
IColonyV15,
} from '../contracts.js';
import { AugmentedIColony, UnknownIColonyClient } from './commonAugments.js';

// Colonies that support the earlier (not-overloaded) method
type ValidColonyA = IColonyV6;

// Colonies that support the later (overloaded) methods
type ValidColonyB =
| IColonyV10
| IColonyV11
| IColonyV12
| IColonyV13
| IColonyV14;
type ValidColonyB = IColonyV12 | IColonyV13 | IColonyV14 | IColonyV15;

const getMoveFundsPermissionProofsA = async (
contract: AugmentedIColony,
Expand Down
10 changes: 2 additions & 8 deletions packages/colony-js/src/clients/Core/augments/augmentsV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@ import {

import { ColonyNetworkClient } from '../../ColonyNetworkClient.js';
import {
IColonyV10,
IColonyV11,
IColonyV12,
IColonyV13,
IColonyV14,
IColonyV15,
} from '../contracts.js';
import {
addAugments as addCommonAugments,
AugmentedIColony,
} from './commonAugments.js';

type ValidColony =
| IColonyV10
| IColonyV11
| IColonyV12
| IColonyV13
| IColonyV14;
type ValidColony = IColonyV12 | IColonyV13 | IColonyV14 | IColonyV15;

export interface AugmentedEstimateV3 {
/**
Expand Down
10 changes: 2 additions & 8 deletions packages/colony-js/src/clients/Core/augments/augmentsV4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {

import { ColonyNetworkClient } from '../../ColonyNetworkClient.js';
import {
IColonyV10,
IColonyV11,
IColonyV12,
IColonyV13,
IColonyV14,
IColonyV15,
} from '../contracts.js';
import { AugmentedIColony } from './commonAugments.js';
import {
Expand All @@ -20,12 +19,7 @@ import {
AugmentedEstimateV3,
} from './augmentsV3.js';

type ValidColony =
| IColonyV10
| IColonyV11
| IColonyV12
| IColonyV13
| IColonyV14;
type ValidColony = IColonyV12 | IColonyV13 | IColonyV14 | IColonyV15;

export interface AugmentedEstimateV4 extends AugmentedEstimateV3 {
/**
Expand Down
10 changes: 2 additions & 8 deletions packages/colony-js/src/clients/Core/augments/augmentsV5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import {

import { ColonyNetworkClient } from '../../ColonyNetworkClient.js';
import {
IColonyV10,
IColonyV11,
IColonyV12,
IColonyV13,
IColonyV14,
IColonyV15,
} from '../contracts.js';
import { AugmentedIColony } from './commonAugments.js';
import { ColonyAugmentsV3 } from './augmentsV3.js';
Expand All @@ -33,12 +32,7 @@ import {
AugmentedEstimateV4,
} from './augmentsV4.js';

type ValidColony =
| IColonyV10
| IColonyV11
| IColonyV12
| IColonyV13
| IColonyV14;
type ValidColony = IColonyV12 | IColonyV13 | IColonyV14 | IColonyV15;

/*
* Estimates
Expand Down
10 changes: 2 additions & 8 deletions packages/colony-js/src/clients/Core/augments/augmentsV6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {

import { ColonyNetworkClient } from '../../ColonyNetworkClient.js';
import {
IColonyV10,
IColonyV11,
IColonyV12,
IColonyV13,
IColonyV14,
IColonyV15,
} from '../contracts.js';
import { AugmentedIColony } from './commonAugments.js';
import { ColonyAugmentsV3 } from './augmentsV3.js';
Expand All @@ -22,12 +21,7 @@ import {
AugmentedEstimateV5,
} from './augmentsV5.js';

type ValidColony =
| IColonyV10
| IColonyV11
| IColonyV12
| IColonyV13
| IColonyV14;
type ValidColony = IColonyV12 | IColonyV13 | IColonyV14 | IColonyV15;

/*
* Estimates
Expand Down
10 changes: 2 additions & 8 deletions packages/colony-js/src/clients/Core/augments/augmentsV7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {

import { ColonyNetworkClient } from '../../ColonyNetworkClient.js';
import {
IColonyV10,
IColonyV11,
IColonyV12,
IColonyV13,
IColonyV14,
IColonyV15,
} from '../contracts.js';
import { AugmentedIColony } from './commonAugments.js';
import { ColonyAugmentsV3 } from './augmentsV3.js';
Expand All @@ -23,12 +22,7 @@ import {
AugmentedEstimateV6,
} from './augmentsV6.js';

type ValidColony =
| IColonyV10
| IColonyV11
| IColonyV12
| IColonyV13
| IColonyV14;
type ValidColony = IColonyV12 | IColonyV13 | IColonyV14 | IColonyV15;

/*
* Estimates
Expand Down
22 changes: 10 additions & 12 deletions packages/colony-js/src/clients/Core/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@ import getColonyClientV6 from './ColonyClientV6.js';
import getColonyClientV7 from './ColonyClientV7.js';
import getColonyClientV8 from './ColonyClientV8.js';
import getColonyClientV9 from './ColonyClientV9.js';
import getColonyClientV10, { ColonyClientV10 } from './ColonyClientV10.js';
import getColonyClientV10 from './ColonyClientV10.js';
import getColonyClientV11, { ColonyClientV11 } from './ColonyClientV11.js';
import getColonyClientV12, { ColonyClientV12 } from './ColonyClientV12.js';
import getColonyClientV13, { ColonyClientV13 } from './ColonyClientV13.js';
import getColonyClientV14, { ColonyClientV14 } from './ColonyClientV14.js';
import getColonyClientV15, { ColonyClientV15 } from './ColonyClientV15.js';

export { ColonyClientV10 } from './ColonyClientV10.js';
export { ColonyClientV11 } from './ColonyClientV11.js';
export { ColonyClientV12 } from './ColonyClientV12.js';
export { ColonyClientV13 } from './ColonyClientV13.js';
export { ColonyClientV14 } from './ColonyClientV14.js';
export { ColonyClientV15 } from './ColonyClientV15.js';

export type AnyColonyClient =
| ColonyClientV10
| ColonyClientV11
| ColonyClientV12
| ColonyClientV13
Expand Down Expand Up @@ -75,71 +73,71 @@ export async function getColonyClient(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 2: {
colonyClient = getColonyClientV2.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 3: {
colonyClient = getColonyClientV3.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 4: {
colonyClient = getColonyClientV4.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 5: {
colonyClient = getColonyClientV5.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 6: {
colonyClient = getColonyClientV6.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 7: {
colonyClient = getColonyClientV7.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 8: {
colonyClient = getColonyClientV8.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 9: {
colonyClient = getColonyClientV9.call(
this,
colonyAddress,
signerOrProvider,
) as ColonyClientV10;
) as ColonyClientV11;
break;
}
case 10: {
Expand Down
Loading

0 comments on commit 587fb30

Please sign in to comment.