From 69cce09823ecb58bee40670e3813fcb5f312b9d0 Mon Sep 17 00:00:00 2001 From: Chris Maniewski Date: Wed, 24 Jul 2024 12:03:30 +0200 Subject: [PATCH] feat: add IVotingReputationClientV12 --- .../VotingReputationClientV12.ts | 45 +++++++++++++++++++ .../VotingReputationClientV6.ts | 35 +++------------ .../augments/CreateDomainMotion.ts | 4 +- .../VotingReputation/augments/augmentsV2.ts | 6 +-- .../VotingReputation/augments/augmentsV3.ts | 4 +- .../Extensions/VotingReputation/contracts.ts | 8 ++-- .../Extensions/VotingReputation/exports.ts | 30 ++++++++----- packages/contractor/package.json | 2 +- .../core/src/versions/VotingReputation.ts | 3 +- pnpm-lock.yaml | 8 ++-- 10 files changed, 88 insertions(+), 57 deletions(-) create mode 100644 packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV12.ts diff --git a/packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV12.ts b/packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV12.ts new file mode 100644 index 000000000..823ba6461 --- /dev/null +++ b/packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV12.ts @@ -0,0 +1,45 @@ +import type { AugmentedIColony } from '../../Core/augments/commonAugments.js'; +import type { IVotingReputation } from '../../../contracts/IVotingReputation/12/IVotingReputation.js'; + +import { IVotingReputation__factory as VotingReputationFactory } from '../../../contracts/IVotingReputation/12/factories/IVotingReputation__factory.js'; +import { ClientType } from '../../../constants.js'; +import { + AugmentedEstimate, + AugmentedVotingReputation, +} from './augments/commonAugments.js'; +import { AugmentedEstimateV2, AugmentsV2 } from './augments/augmentsV2.js'; +import { + addAugments as addAugmentsV3, + AugmentedEstimateV3, + AugmentsV3, +} from './augments/augmentsV3.js'; + +interface VotingReputationEstimate + extends AugmentedEstimate, + AugmentedEstimateV2, + AugmentedEstimateV3 {} + +export interface VotingReputationClientV12 + extends AugmentedVotingReputation, + AugmentsV2, + AugmentsV3 { + clientVersion: 12; + estimateGas: VotingReputationEstimate; +} + +export default function getVotingReputationClient( + colonyClient: AugmentedIColony, + address: string, +): VotingReputationClientV12 { + const votingReputationClient = VotingReputationFactory.connect( + address, + colonyClient.signer || colonyClient.provider, + ) as VotingReputationClientV12; + + votingReputationClient.clientType = ClientType.VotingReputationClient; + votingReputationClient.clientVersion = 12; + + addAugmentsV3(votingReputationClient, colonyClient); + + return votingReputationClient; +} diff --git a/packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV6.ts b/packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV6.ts index cd8611840..b4c1dfd83 100644 --- a/packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV6.ts +++ b/packages/colony-js/src/clients/Extensions/VotingReputation/VotingReputationClientV6.ts @@ -1,44 +1,19 @@ import type { AugmentedIColony } from '../../Core/augments/commonAugments.js'; -import type { IVotingReputation } from '../../../contracts/IVotingReputation/6/IVotingReputation.js'; import { IVotingReputation__factory as VotingReputationFactory } from '../../../contracts/IVotingReputation/6/factories/IVotingReputation__factory.js'; import { ClientType } from '../../../constants.js'; -import { - AugmentedEstimate, - AugmentedVotingReputation, -} from './augments/commonAugments.js'; -import { - addAugments, - AugmentedEstimateV2, - AugmentsV2, -} from './augments/augmentsV2.js'; -import { - addAugments as addCreateDomainMotionAugments, - CreateDomainMotionAugments, - CreateDomainMotionEstimateGas, -} from './augments/CreateDomainMotion.js'; - -interface VotingReputationEstimate - extends AugmentedEstimate, - AugmentedEstimateV2, - CreateDomainMotionEstimateGas {} - -export interface VotingReputationClientV6 - extends AugmentedVotingReputation, - AugmentsV2, - CreateDomainMotionAugments { - clientVersion: 6; - estimateGas: VotingReputationEstimate; -} +import { UnkonwnVotingReputationClient } from './augments/commonAugments.js'; +import { addAugments } from './augments/augmentsV2.js'; +import { addAugments as addCreateDomainMotionAugments } from './augments/CreateDomainMotion.js'; export default function getVotingReputationClient( colonyClient: AugmentedIColony, address: string, -): VotingReputationClientV6 { +) { const votingReputationClient = VotingReputationFactory.connect( address, colonyClient.signer || colonyClient.provider, - ) as VotingReputationClientV6; + ) as UnkonwnVotingReputationClient; votingReputationClient.clientType = ClientType.VotingReputationClient; votingReputationClient.clientVersion = 6; diff --git a/packages/colony-js/src/clients/Extensions/VotingReputation/augments/CreateDomainMotion.ts b/packages/colony-js/src/clients/Extensions/VotingReputation/augments/CreateDomainMotion.ts index 6eb499db4..5c72b18d4 100644 --- a/packages/colony-js/src/clients/Extensions/VotingReputation/augments/CreateDomainMotion.ts +++ b/packages/colony-js/src/clients/Extensions/VotingReputation/augments/CreateDomainMotion.ts @@ -11,11 +11,11 @@ import { parsePermissionedAction, } from '@colony/core'; -import { VotingReputationV6, VotingReputationV7 } from '../contracts.js'; +import { VotingReputationV7 } from '../contracts.js'; import { AugmentedVotingReputation } from './commonAugments.js'; // VotingReputation versions that support this method -type ValidVotingReputation = VotingReputationV6 | VotingReputationV7; +type ValidVotingReputation = VotingReputationV7; const { MaxUint256 } = constants; diff --git a/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV2.ts b/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV2.ts index 6bdf3da84..8aa7f23c0 100644 --- a/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV2.ts +++ b/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV2.ts @@ -8,12 +8,12 @@ import { type TxOverrides, getCreateMotionProofs } from '@colony/core'; import { AugmentedIColony } from '../../../Core/augments/commonAugments.js'; import { - VotingReputationV6, VotingReputationV7, VotingReputationV8, VotingReputationV9, VotingReputationV10, VotingReputationV11, + VotingReputationV12, } from '../contracts.js'; import { AnyVotingReputationClient } from '../exports.js'; import { @@ -22,12 +22,12 @@ import { } from './commonAugments.js'; type ValidVotingReputation = - | VotingReputationV6 | VotingReputationV7 | VotingReputationV8 | VotingReputationV9 | VotingReputationV10 - | VotingReputationV11; + | VotingReputationV11 + | VotingReputationV12; export interface AugmentedEstimateV2 { /** diff --git a/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV3.ts b/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV3.ts index daace32ba..ce68e8a6b 100644 --- a/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV3.ts +++ b/packages/colony-js/src/clients/Extensions/VotingReputation/augments/augmentsV3.ts @@ -12,6 +12,7 @@ import { VotingReputationV9, VotingReputationV10, VotingReputationV11, + VotingReputationV12, } from '../contracts.js'; import { AugmentedVotingReputation } from './commonAugments.js'; import { addAugments as addAugmentsV2, AugmentsV2 } from './augmentsV2.js'; @@ -21,7 +22,8 @@ type ValidVotingReputation = | VotingReputationV8 | VotingReputationV9 | VotingReputationV10 - | VotingReputationV11; + | VotingReputationV11 + | VotingReputationV12; export interface AugmentedEstimateV3 { /** diff --git a/packages/colony-js/src/clients/Extensions/VotingReputation/contracts.ts b/packages/colony-js/src/clients/Extensions/VotingReputation/contracts.ts index 9ce1f99ed..84e259df7 100644 --- a/packages/colony-js/src/clients/Extensions/VotingReputation/contracts.ts +++ b/packages/colony-js/src/clients/Extensions/VotingReputation/contracts.ts @@ -10,8 +10,9 @@ import type { IVotingReputation as VotingReputation8 } from '../../../contracts/ import type { IVotingReputation as VotingReputation9 } from '../../../contracts/IVotingReputation/9/index.js'; import type { IVotingReputation as VotingReputation10 } from '../../../contracts/IVotingReputation/10/index.js'; import type { IVotingReputation as VotingReputation11 } from '../../../contracts/IVotingReputation/11/index.js'; +import type { IVotingReputation as VotingReputation12 } from '../../../contracts/IVotingReputation/12/index.js'; -export { IVotingReputation__factory as VotingReputationFactory } from '../../../contracts/IVotingReputation/11/factories/IVotingReputation__factory.js'; +export { IVotingReputation__factory as VotingReputationFactory } from '../../../contracts/IVotingReputation/12/factories/IVotingReputation__factory.js'; export type VotingReputationV1 = VotingReputation1; export type VotingReputationV2 = VotingReputation2; @@ -24,11 +25,12 @@ export type VotingReputationV8 = VotingReputation8; export type VotingReputationV9 = VotingReputation9; export type VotingReputationV10 = VotingReputation10; export type VotingReputationV11 = VotingReputation11; +export type VotingReputationV12 = VotingReputation12; export type AnyVotingReputation = - | VotingReputation6 | VotingReputation7 | VotingReputation8 | VotingReputation9 | VotingReputation10 - | VotingReputation11; + | VotingReputation11 + | VotingReputation12; diff --git a/packages/colony-js/src/clients/Extensions/VotingReputation/exports.ts b/packages/colony-js/src/clients/Extensions/VotingReputation/exports.ts index 1012b3031..7191ad227 100644 --- a/packages/colony-js/src/clients/Extensions/VotingReputation/exports.ts +++ b/packages/colony-js/src/clients/Extensions/VotingReputation/exports.ts @@ -9,9 +9,7 @@ import getVotingReputationClientV2 from './VotingReputationClientV2.js'; import getVotingReputationClientV3 from './VotingReputationClientV3.js'; import getVotingReputationClientV4 from './VotingReputationClientV4.js'; import getVotingReputationClientV5 from './VotingReputationClientV5.js'; -import getVotingReputationClientV6, { - VotingReputationClientV6, -} from './VotingReputationClientV6.js'; +import getVotingReputationClientV6 from './VotingReputationClientV6.js'; import getVotingReputationClientV7, { VotingReputationClientV7, } from './VotingReputationClientV7.js'; @@ -27,21 +25,24 @@ import getVotingReputationClientV10, { import getVotingReputationClientV11, { VotingReputationClientV11, } from './VotingReputationClientV11.js'; +import getVotingReputationClientV12, { + VotingReputationClientV12, +} from './VotingReputationClientV12.js'; -export { VotingReputationClientV6 } from './VotingReputationClientV6.js'; export { VotingReputationClientV7 } from './VotingReputationClientV7.js'; export { VotingReputationClientV8 } from './VotingReputationClientV8.js'; export { VotingReputationClientV9 } from './VotingReputationClientV9.js'; export { VotingReputationClientV10 } from './VotingReputationClientV10.js'; export { VotingReputationClientV11 } from './VotingReputationClientV11.js'; +export { VotingReputationClientV12 } from './VotingReputationClientV12.js'; export type AnyVotingReputationClient = - | VotingReputationClientV6 | VotingReputationClientV7 | VotingReputationClientV8 | VotingReputationClientV9 | VotingReputationClientV10 - | VotingReputationClientV11; + | VotingReputationClientV11 + | VotingReputationClientV12; /** @internal */ export function getVotingReputationClient( @@ -54,29 +55,32 @@ export function getVotingReputationClient( return getVotingReputationClientV1( colonyClient, address, - ) as VotingReputationClientV6; + ) as VotingReputationClientV7; case 2: return getVotingReputationClientV2( colonyClient, address, - ) as VotingReputationClientV6; + ) as VotingReputationClientV7; case 3: return getVotingReputationClientV3( colonyClient, address, - ) as VotingReputationClientV6; + ) as VotingReputationClientV7; case 4: return getVotingReputationClientV4( colonyClient, address, - ) as VotingReputationClientV6; + ) as VotingReputationClientV7; case 5: return getVotingReputationClientV5( colonyClient, address, - ) as VotingReputationClientV6; + ) as VotingReputationClientV7; case 6: - return getVotingReputationClientV6(colonyClient, address); + return getVotingReputationClientV6( + colonyClient, + address, + ) as VotingReputationClientV7; case 7: return getVotingReputationClientV7(colonyClient, address); case 8: @@ -87,6 +91,8 @@ export function getVotingReputationClient( return getVotingReputationClientV10(colonyClient, address); case 11: return getVotingReputationClientV11(colonyClient, address); + case 12: + return getVotingReputationClientV12(colonyClient, address); default: return assertExhaustiveSwitch( version, diff --git a/packages/contractor/package.json b/packages/contractor/package.json index 20444f0b9..5e3d7c00e 100644 --- a/packages/contractor/package.json +++ b/packages/contractor/package.json @@ -30,7 +30,7 @@ }, "homepage": "https://docs.colony.io/develop", "dependencies": { - "@colony/abis": "0.0.0-snapshot-next-b8f19a6-1ea75dc3-20240717122511", + "@colony/abis": "0.0.0-snapshot-next-8f62df3-e0fd1a8f-20240724094300", "@typechain/ethers-v5": "^11.1.0", "@typechain/ethers-v6": "^0.4.2", "@types/mkdirp": "^1.0.2", diff --git a/packages/core/src/versions/VotingReputation.ts b/packages/core/src/versions/VotingReputation.ts index d27fc4a85..25be91dc6 100644 --- a/packages/core/src/versions/VotingReputation.ts +++ b/packages/core/src/versions/VotingReputation.ts @@ -2,7 +2,7 @@ import type { ColonyVersion } from './IColony.js'; import { createContractVersionArray } from './utils.js'; -const VOTING_REPUTATION_VERSION_NEXT = 12; +const VOTING_REPUTATION_VERSION_NEXT = 13; /** @internal */ export const VOTING_REPUTATION_VERSIONS = createContractVersionArray( @@ -28,6 +28,7 @@ export const votingReputationIncompatibilityMap: Record< 9: [1, 2, 3, 4, 5, 6], 10: [1, 2, 3, 4, 5, 6], 11: [1, 2, 3, 4, 5, 6], + 12: [1, 2, 3, 4, 5, 6], }; /** @internal */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 601e20b9f..a5f5090c8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -115,8 +115,8 @@ importers: packages/contractor: dependencies: '@colony/abis': - specifier: 0.0.0-snapshot-next-b8f19a6-1ea75dc3-20240717122511 - version: 0.0.0-snapshot-next-b8f19a6-1ea75dc3-20240717122511 + specifier: 0.0.0-snapshot-next-8f62df3-e0fd1a8f-20240724094300 + version: 0.0.0-snapshot-next-8f62df3-e0fd1a8f-20240724094300 '@typechain/ethers-v5': specifier: ^11.1.0 version: 11.1.0(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(typechain@8.3.0)(typescript@5.1.6) @@ -828,8 +828,8 @@ packages: prettier: 2.8.8 dev: false - /@colony/abis@0.0.0-snapshot-next-b8f19a6-1ea75dc3-20240717122511: - resolution: {integrity: sha512-UvPzT/cFrB/DcB7y3mhY2jBV56CdZzphk+gYEyfNoo9WqC8bmv+BjjEg1bztyk8bRKLjHdemZ3POF98CTbeelg==} + /@colony/abis@0.0.0-snapshot-next-8f62df3-e0fd1a8f-20240724094300: + resolution: {integrity: sha512-OnQFX1IHYDeZs9ZGb3veIO9HLKOHa490+LgRXNbhXVJj/ySv6LYW2vqqyiLtrrVljV0N+zLPDrc5ecrplzkCXg==} engines: {node: ^16 || ^18 || ^20, npm: ^8 || ^9 || ^10} dev: false