Skip to content

Commit

Permalink
Fix imports by moving util
Browse files Browse the repository at this point in the history
  • Loading branch information
davecreaser committed Aug 22, 2024
1 parent ae1afe1 commit 2621e98
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 96 deletions.
94 changes: 92 additions & 2 deletions packages/core/src/versions/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,97 @@
import { Extension } from '../constants.js';
import { COLONY_VERSIONS } from './IColony.js';
import { ColonyVersion, ExtensionVersion } from './index.js';
import { getExtensionIncompatibilityMap } from './utils.js';
import { assertExhaustiveSwitch } from '../utils/index.js';
import {
fundingQueueIncompatibilityMap,
FundingQueueVersion,
} from './FundingQueue.js';
import {
oneTxPaymentIncompatibilityMap,
OneTxPaymentVersion,
} from './OneTxPayment.js';
import {
reputationBootstrapperIncompatibilityMap,
ReputationBootstrapperVersion,
} from './ReputationBootstrapper.js';
import {
stagedExpenditureIncompatibilityMap,
StagedExpenditureVersion,
} from './StagedExpenditure.js';
import {
stakedExpenditureIncompatibilityMap,
StakedExpenditureVersion,
} from './StakedExpenditure.js';
import {
streamingPaymentsIncompatibilityMap,
StreamingPaymentsVersion,
} from './StreamingPayments.js';
import {
tokenSupplierIncompatibilityMap,
TokenSupplierVersion,
} from './TokenSupplier.js';
import {
votingReputationIncompatibilityMap,
VotingReputationVersion,
} from './VotingReputation.js';
import { Extension } from '../constants.js';

const getExtensionIncompatibilityMap = (
extension: Extension,
extensionVersion: ExtensionVersion,
) => {
switch (extension) {
case Extension.FundingQueue: {
return fundingQueueIncompatibilityMap[
extensionVersion as FundingQueueVersion
];
}
case Extension.IVotingReputation: {
return votingReputationIncompatibilityMap[
extensionVersion as VotingReputationVersion
];
}
case Extension.OneTxPayment: {
return oneTxPaymentIncompatibilityMap[
extensionVersion as OneTxPaymentVersion
];
}
case Extension.ReputationBootstrapper: {
return reputationBootstrapperIncompatibilityMap[
extensionVersion as ReputationBootstrapperVersion
];
}
case Extension.StagedExpenditure: {
return stagedExpenditureIncompatibilityMap[
extensionVersion as StagedExpenditureVersion
];
}
case Extension.StakedExpenditure: {
return stakedExpenditureIncompatibilityMap[
extensionVersion as StakedExpenditureVersion
];
}
case Extension.StreamingPayments: {
return streamingPaymentsIncompatibilityMap[
extensionVersion as StreamingPaymentsVersion
];
}
case Extension.TokenSupplier: {
return tokenSupplierIncompatibilityMap[
extensionVersion as TokenSupplierVersion
];
}
case Extension.VotingReputation: {
return votingReputationIncompatibilityMap[
extensionVersion as VotingReputationVersion
];
}
default:
return assertExhaustiveSwitch(
extension,
'Could not find extension with name',
);
}
};

/**
* Checks the compatibility of an extension version with a colony version it requests to be installed in
Expand Down
94 changes: 0 additions & 94 deletions packages/core/src/versions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
import { Extension } from '../constants.js';
import { assertExhaustiveSwitch } from '../utils/index.js';
import {
fundingQueueIncompatibilityMap,
FundingQueueVersion,
} from './FundingQueue.js';
import { ExtensionVersion } from './index.js';
import {
oneTxPaymentIncompatibilityMap,
OneTxPaymentVersion,
} from './OneTxPayment.js';
import {
reputationBootstrapperIncompatibilityMap,
ReputationBootstrapperVersion,
} from './ReputationBootstrapper.js';
import {
stagedExpenditureIncompatibilityMap,
StagedExpenditureVersion,
} from './StagedExpenditure.js';
import {
stakedExpenditureIncompatibilityMap,
StakedExpenditureVersion,
} from './StakedExpenditure.js';
import {
streamingPaymentsIncompatibilityMap,
StreamingPaymentsVersion,
} from './StreamingPayments.js';
import {
tokenSupplierIncompatibilityMap,
TokenSupplierVersion,
} from './TokenSupplier.js';
import {
votingReputationIncompatibilityMap,
VotingReputationVersion,
} from './VotingReputation.js';

type Enumerate<
N extends number,
Acc extends number[] = [],
Expand All @@ -51,61 +15,3 @@ export const createContractVersionArray = <T extends number>(last: T) => {
(i) => (i + 1) as Range<1, typeof last>,
);
};

export const getExtensionIncompatibilityMap = (
extension: Extension,
extensionVersion: ExtensionVersion,
) => {
switch (extension) {
case Extension.FundingQueue: {
return fundingQueueIncompatibilityMap[
extensionVersion as FundingQueueVersion
];
}
case Extension.IVotingReputation: {
return votingReputationIncompatibilityMap[
extensionVersion as VotingReputationVersion
];
}
case Extension.OneTxPayment: {
return oneTxPaymentIncompatibilityMap[
extensionVersion as OneTxPaymentVersion
];
}
case Extension.ReputationBootstrapper: {
return reputationBootstrapperIncompatibilityMap[
extensionVersion as ReputationBootstrapperVersion
];
}
case Extension.StagedExpenditure: {
return stagedExpenditureIncompatibilityMap[
extensionVersion as StagedExpenditureVersion
];
}
case Extension.StakedExpenditure: {
return stakedExpenditureIncompatibilityMap[
extensionVersion as StakedExpenditureVersion
];
}
case Extension.StreamingPayments: {
return streamingPaymentsIncompatibilityMap[
extensionVersion as StreamingPaymentsVersion
];
}
case Extension.TokenSupplier: {
return tokenSupplierIncompatibilityMap[
extensionVersion as TokenSupplierVersion
];
}
case Extension.VotingReputation: {
return votingReputationIncompatibilityMap[
extensionVersion as VotingReputationVersion
];
}
default:
return assertExhaustiveSwitch(
extension,
'Could not find extension with name',
);
}
};

0 comments on commit 2621e98

Please sign in to comment.