Skip to content

Commit

Permalink
Revert "fix: checks"
Browse files Browse the repository at this point in the history
This reverts commit d92410a.
  • Loading branch information
PsicoThePato committed Oct 7, 2024
1 parent 4adf940 commit adcc015
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 45 deletions.
7 changes: 3 additions & 4 deletions apps/commune-worker/src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

export type NewVote = typeof daoVoteSchema.$inferInsert;
export type Module = typeof moduleData.$inferInsert;
export type Subnet = typeof subnetDataSchema.$inferInsert;
export type Subnet = typeof subnetDataSchema.$inferInsert

export type NewNotification = typeof governanceNotificationSchema.$inferInsert;

Expand Down Expand Up @@ -40,8 +40,7 @@ export async function upsertSubnetData(subnets: Subnet[]) {
proposalExpiration: s.proposalExpiration,
voteMode: s.voteMode,
proposalRewardTreasuryAllocation: s.proposalRewardTreasuryAllocation,
maxProposalRewardTreasuryAllocation:
s.maxProposalRewardTreasuryAllocation,
maxProposalRewardTreasuryAllocation: s.maxProposalRewardTreasuryAllocation,
proposalRewardInterval: s.proposalRewardInterval,
minBurn: s.minBurn,
maxBurn: s.maxBurn,
Expand All @@ -51,8 +50,8 @@ export async function upsertSubnetData(subnets: Subnet[]) {
maxRegistrationsPerInterval: s.maxRegistrationsPerInterval,
minValidatorStake: s.minValidatorStake,
maxAllowedValidators: s.maxAllowedValidators,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
atBlock: s.atBlock,

})),
)
.onConflictDoUpdate({
Expand Down
45 changes: 17 additions & 28 deletions apps/commune-worker/src/db/type-transformations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import type { NetworkSubnetConfig, SubspaceModule } from "@commune-ts/types";
import type { SubspaceModule, NetworkSubnetConfig } from "@commune-ts/types";

import type { Module, Subnet } from "./index.js";

Expand All @@ -28,10 +25,8 @@ export function SubspaceModuleToDatabase(
};
}

export function SubnetToDatabase(
subnet: NetworkSubnetConfig,
atBlock: number,
): Subnet {

export function SubnetToDatabase(subnet: NetworkSubnetConfig, atBlock: number): Subnet {
return {
netuid: subnet.netuid,
name: subnet.subnetNames,
Expand All @@ -44,31 +39,25 @@ export function SubnetToDatabase(
founderShare: subnet.founderShare,
incentiveRatio: subnet.incentiveRatio,
trustRatio: subnet.trustRatio,
maxWeightAge: String(subnet.maxWeightAge),
maxWeightAge: subnet.maxWeightAge,
bondsMa: subnet.bondsMovingAverage ?? null,
maximumSetWeightCallsPerEpoch: subnet.maximumSetWeightCallsPerEpoch ?? null,
minValidatorStake: BigInt(subnet.minValidatorStake),
minValidatorStake: subnet.minValidatorStake ?? null,

Check failure on line 45 in apps/commune-worker/src/db/type-transformations.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
maxAllowedValidators: subnet.maxAllowedValidators ?? null,
subnetMetadata: subnet.subnetMetadata,
minBurn: BigInt(subnet.moduleBurnConfig.minBurn),
maxBurn: BigInt(subnet.moduleBurnConfig.maxBurn),
adjustmentAlpha: String(subnet.moduleBurnConfig.adjustmentAlpha),
targetRegistrationsInterval:
subnet.moduleBurnConfig.targetRegistrationsInterval,
maxRegistrationsPerInterval:
subnet.moduleBurnConfig.maxRegistrationsPerInterval,
proposalCost: BigInt(subnet.subnetGovernanceConfig.proposalCost),
minBurn: subnet.moduleBurnConfig.minBurn,
maxBurn: subnet.moduleBurnConfig.maxBurn,
adjustmentAlpha: subnet.moduleBurnConfig.adjustmentAlpha,
targetRegistrationsInterval: subnet.moduleBurnConfig.targetRegistrationsInterval,
maxRegistrationsPerInterval: subnet.moduleBurnConfig.maxRegistrationsPerInterval,
proposalCost: subnet.subnetGovernanceConfig.proposalCost,
proposalExpiration: subnet.subnetGovernanceConfig.proposalExpiration,
maxProposalRewardTreasuryAllocation: BigInt(
subnet.subnetGovernanceConfig.maxProposalRewardTreasuryAllocation,
),
proposalRewardTreasuryAllocation:
subnet.subnetGovernanceConfig.proposalRewardTreasuryAllocation,
proposalRewardInterval:
subnet.subnetGovernanceConfig.proposalRewardInterval,
targetRegistrationsPerInterval:
subnet.moduleBurnConfig.targetRegistrationsPerInterval,
maxProposalRewardTreasuryAllocation: subnet.subnetGovernanceConfig.maxProposalRewardTreasuryAllocation,
proposalRewardTreasuryAllocation: subnet.subnetGovernanceConfig.proposalRewardTreasuryAllocation,
proposalRewardInterval: subnet.subnetGovernanceConfig.proposalRewardInterval,
targetRegistrationsPerInterval: subnet.moduleBurnConfig.targetRegistrationsPerInterval,
subnetEmission: subnet.subnetEmission,
atBlock: atBlock,
voteMode: subnet.subnetGovernanceConfig.voteMode,
};
}
}
2 changes: 1 addition & 1 deletion apps/commune-worker/src/workers/subnet-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function subnetFetcherWorker(props: WorkerProps) {
SubnetToDatabase(subnet, props.lastBlock.blockNumber),
);
log(
`Block ${props.lastBlock.blockNumber}: upserting ${subnetData.length} subnets`,
`Block ${props.lastBlock.blockNumber}: upserting ${subnetData.length} modules`,
);
await upsertSubnetData(subnetData);

Expand Down
13 changes: 3 additions & 10 deletions packages/db/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
bigint,
index,
integer,
numeric,
pgEnum,
pgTableCreator,
pgView,
real,
serial,
numeric,
text,
timestamp,
unique,
Expand Down Expand Up @@ -103,10 +103,7 @@ export const subnetDataSchema = createTable(
minAllowedWeights: integer("min_allowed_weights").notNull(),
maxAllowedWeights: integer("max_allowed_weights").notNull(),
maxAllowedUids: integer("max_allowed_uids").notNull(),
maxWeightAge: numeric("max_weight_age", {
precision: 20,
scale: 0,
}).notNull(),
maxWeightAge: numeric("max_weight_age", { precision: 20, scale: 0 }).notNull(),
trustRatio: integer("trust_ratio").notNull(),
founderShare: integer("founder_share").notNull(),
incentiveRatio: integer("incentive_ratio").notNull(),
Expand All @@ -132,10 +129,7 @@ export const subnetDataSchema = createTable(
// BurnConfiguration fields
minBurn: bigint("min_burn", { mode: "bigint" }).notNull(),
maxBurn: bigint("max_burn", { mode: "bigint" }).notNull(),
adjustmentAlpha: numeric("adjustment_alpha", {
precision: 20,
scale: 0,
}).notNull(),
adjustmentAlpha: numeric("adjustment_alpha", { precision: 20, scale: 0 }).notNull(),
targetRegistrationsInterval: integer(
"target_registrations_interval",
).notNull(),
Expand All @@ -148,7 +142,6 @@ export const subnetDataSchema = createTable(
// Additional fields
minValidatorStake: bigint("min_validator_stake", { mode: "bigint" }),
maxAllowedValidators: integer("max_allowed_validators"),
// subnetEmission: bigint("subnet_emission", { mode: "bigint" }),
createdAt: timestamp("created_at").defaultNow().notNull(),
deletedAt: timestamp("deleted_at").default(sql`null`),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const buttonVariants = cva(
variant: {
base: "border",
default:
"border border-white/20 bg-[#898989]/5 bg-background text-white hover:border-green-500 hover:bg-background-green hover:text-green-500 active:bg-green-500/40",
"hover:bg-background-green border border-white/20 bg-[#898989]/5 bg-background text-white hover:border-green-500 hover:text-green-500 active:bg-green-500/40",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
ghost: "hover:bg-accent hover:text-accent-foreground",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SelectTrigger = React.forwardRef<
<SelectPrimitive.Trigger
ref={ref}
className={cn(
"flex h-9 w-full items-center justify-between whitespace-nowrap border border-input border-white/20 bg-background px-3 py-2 text-sm shadow-sm ring-offset-background transition duration-200 placeholder:text-muted-foreground hover:border-green-500 hover:bg-background-green hover:text-green-500 focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
"hover:bg-background-green flex h-9 w-full items-center justify-between whitespace-nowrap border border-input border-white/20 bg-background px-3 py-2 text-sm shadow-sm ring-offset-background transition duration-200 placeholder:text-muted-foreground hover:border-green-500 hover:text-green-500 focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
className,
)}
{...props}
Expand Down

0 comments on commit adcc015

Please sign in to comment.