Skip to content

Commit 178258b

Browse files
authored
Merge pull request #3349 from ava-labs/owen/staking-manager-deployment
`Console`: Filter for Native Token Staking Manager code in Owen's PR #2880
2 parents 6e7133a + 825701f commit 178258b

File tree

25 files changed

+4059
-74
lines changed

25 files changed

+4059
-74
lines changed

app/console/history/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ export default function ConsoleHistoryPage() {
100100
type: 'address'
101101
});
102102
}
103-
if (toolboxStore.stakingManagerAddress && toolboxStore.stakingManagerAddress !== '') {
103+
if (toolboxStore.nativeStakingManagerAddress && toolboxStore.nativeStakingManagerAddress !== '') {
104104
items.push({
105-
id: 'tb-staking-mgr',
106-
title: 'Staking Manager',
105+
id: 'tb-native-staking-mgr',
106+
title: 'Native Token Staking Manager',
107107
description: 'Deployed Contract',
108-
address: toolboxStore.stakingManagerAddress,
108+
address: toolboxStore.nativeStakingManagerAddress,
109109
chainId,
110110
type: 'address'
111111
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use client";
2+
3+
import StepFlow from "@/components/console/step-flow";
4+
import { steps } from "../steps";
5+
6+
export default function NativeStakingManagerSetupClientPage({ currentStepKey }: { currentStepKey: string }) {
7+
const basePath = "/console/permissionless-l1s/native-staking-manager-setup";
8+
return (
9+
<StepFlow
10+
steps={steps}
11+
basePath={basePath}
12+
currentStepKey={currentStepKey}
13+
/>
14+
);
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import NativeStakingManagerSetupClientPage from "./client-page";
2+
3+
export default async function Page({ params }: { params: Promise<{ step: string }> }) {
4+
const { step } = await params;
5+
return (
6+
<NativeStakingManagerSetupClientPage currentStepKey={step} />
7+
);
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { redirect } from "next/navigation";
2+
3+
export default function Page() {
4+
redirect("/console/permissionless-l1s/native-staking-manager-setup/deploy-native-token-staking-manager");
5+
}
6+
7+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { type StepDefinition } from "@/components/console/step-flow";
2+
import ReadContract from "@/components/toolbox/console/permissioned-l1s/validator-manager-setup/ReadContract";
3+
import DeployNativeTokenStakingManager from "@/components/toolbox/console/permissionless-l1s/setup/native/DeployNativeStakingManager";
4+
import InitializeNativeTokenStakingManager from "@/components/toolbox/console/permissionless-l1s/setup/native/InitializeNativeStakingManager";
5+
import DeployExampleRewardCalculator from "@/components/toolbox/console/permissionless-l1s/setup/DeployExampleRewardCalculator";
6+
import TransferOwnershipToStakingManager from "@/components/toolbox/console/permissionless-l1s/setup/TransferOwnershipToStakingManager";
7+
import EnableStakingManagerMinting from "@/components/toolbox/console/permissionless-l1s/setup/native/EnableStakingManagerMinting";
8+
9+
export const steps: StepDefinition[] = [
10+
{
11+
type: "single",
12+
key: "deploy-native-token-staking-manager",
13+
title: "Deploy Staking Manager",
14+
component: DeployNativeTokenStakingManager,
15+
},
16+
{ type: "single", key: "deploy-example-reward-calculator", title: "Deploy Example Reward Calculator", component: DeployExampleRewardCalculator },
17+
{
18+
type: "single",
19+
key: "initialize-native-staking-manager",
20+
title: "Initialize Staking Manager",
21+
component: InitializeNativeTokenStakingManager,
22+
},
23+
{ type: "single", key: "enable-staking-minting", title: "Enable StakingManager in Native Minter", component: EnableStakingManagerMinting },
24+
{ type: "single", key: "transfer-ownership", title: "Transfer Ownership to Staking Manager", component: TransferOwnershipToStakingManager },
25+
{ type: "single", key: "read-contract", title: "Read Contract", component: ReadContract },
26+
];

components/console/console-sidebar.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,9 @@ const data = {
230230
icon: Globe,
231231
items: [
232232
{
233-
title: "Migrate from Permissioned L1",
234-
url: "/console/permissionless-l1s/deploy-reward-manager",
233+
title: "Native Staking Manager Setup",
234+
url: "/console/permissionless-l1s/native-staking-manager-setup",
235235
icon: GitMerge,
236-
comingSoon: true,
237-
},
238-
{
239-
title: "Stake & Unstake",
240-
url: "/console/permissionless-l1s/manage-validators",
241-
icon: Hexagon,
242-
comingSoon: true,
243236
},
244237
],
245238
},

components/toolbox/components/AllowListComponents.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ function SetEnabledComponent({
1515
precompileType = "precompiled contract",
1616
abi = allowListAbi.abi,
1717
onSuccess,
18+
defaultAddress,
1819
}: {
1920
precompileAddress: string;
2021
precompileType?: string;
2122
abi?: any;
2223
onSuccess?: () => void;
24+
defaultAddress?: string;
2325
}) {
2426
const { publicClient, walletEVMAddress, walletChainId } =
2527
useWalletStore();
2628
const { coreWalletClient } = useConnectedWallet();
2729
const viemChain = useViemChainStore();
2830
const [isProcessing, setIsProcessing] = useState(false);
29-
const [enabledAddress, setEnabledAddress] = useState<string>("");
31+
const [enabledAddress, setEnabledAddress] = useState<string>(defaultAddress || "");
3032
const [txHash, setTxHash] = useState<string | null>(null);
3133
const [error, setError] = useState<string | null>(null);
3234

@@ -523,11 +525,13 @@ export function AllowlistComponent({
523525
precompileType = "precompiled contract",
524526
abi = allowListAbi.abi,
525527
onSuccess,
528+
defaultEnabledAddress,
526529
}: {
527530
precompileAddress: string;
528531
precompileType?: string;
529532
abi?: any;
530533
onSuccess?: () => void;
534+
defaultEnabledAddress?: string;
531535
}) {
532536
return (
533537
<div className="space-y-6">
@@ -538,6 +542,7 @@ export function AllowlistComponent({
538542
precompileType={precompileType}
539543
abi={abi}
540544
onSuccess={onSuccess}
545+
defaultAddress={defaultEnabledAddress}
541546
/>
542547
<SetManagerComponent
543548
precompileAddress={precompileAddress}

components/toolbox/components/CheckPrecompile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ export const CheckPrecompile = ({
116116
}
117117

118118
return <>{children}</>;
119-
};
119+
};

components/toolbox/components/ValidatorListInput.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface ValidatorListInputProps {
2929
maxValidators?: number;
3030
selectedSubnetId?: string | null;
3131
isTestnet?: boolean;
32+
hideConsensusWeight?: boolean;
3233
}
3334

3435
export function ValidatorListInput({
@@ -42,6 +43,7 @@ export function ValidatorListInput({
4243
maxValidators,
4344
selectedSubnetId = null,
4445
isTestnet = false,
46+
hideConsensusWeight = false,
4547
}: ValidatorListInputProps) {
4648

4749
const [error, setError] = useState<string | null>(null)
@@ -85,6 +87,7 @@ export function ValidatorListInput({
8587
onChange={onChange}
8688
l1TotalInitializedWeight={l1TotalInitializedWeight}
8789
userPChainBalanceNavax={userPChainBalanceNavax}
90+
hideConsensusWeight={hideConsensusWeight}
8891
/>
8992
</div>
9093
</div>

components/toolbox/components/ValidatorListInput/ValidatorItem.tsx

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface Props {
1414
onUpdate: (index: number, updated: Partial<ConvertToL1Validator>) => void
1515
l1TotalInitializedWeight?: bigint | null
1616
userPChainBalanceNavax?: bigint | null
17+
hideConsensusWeight?: boolean
1718
}
1819

1920
export function ValidatorItem({
@@ -25,6 +26,7 @@ export function ValidatorItem({
2526
onUpdate,
2627
l1TotalInitializedWeight = null,
2728
userPChainBalanceNavax = null,
29+
hideConsensusWeight = false,
2830
}: Props) {
2931

3032
let insufficientBalanceError: string | null = null
@@ -89,29 +91,31 @@ export function ValidatorItem({
8991
/>
9092
</div>
9193

92-
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
93-
<div className="space-y-2">
94-
<label className="block text-sm font-medium text-zinc-700 dark:text-zinc-300">
95-
Consensus Weight
96-
</label>
97-
<input
98-
type="number"
99-
value={validator.validatorWeight.toString()}
100-
onChange={(e) => onUpdate(index, { validatorWeight: BigInt(e.target.value || 0) })}
101-
className={cn(
102-
"w-full rounded p-2",
103-
"bg-zinc-50 dark:bg-zinc-900",
104-
"border border-zinc-200 dark:border-zinc-700",
105-
"text-zinc-900 dark:text-zinc-100",
106-
"shadow-sm focus:ring focus:ring-primary/30 focus:ring-opacity-50",
94+
<div className={cn("grid gap-3", hideConsensusWeight ? "grid-cols-1" : "grid-cols-1 md:grid-cols-2")}>
95+
{!hideConsensusWeight && (
96+
<div className="space-y-2">
97+
<label className="block text-sm font-medium text-zinc-700 dark:text-zinc-300">
98+
Consensus Weight
99+
</label>
100+
<input
101+
type="number"
102+
value={validator.validatorWeight.toString()}
103+
onChange={(e) => onUpdate(index, { validatorWeight: BigInt(e.target.value || 0) })}
104+
className={cn(
105+
"w-full rounded p-2",
106+
"bg-zinc-50 dark:bg-zinc-900",
107+
"border border-zinc-200 dark:border-zinc-700",
108+
"text-zinc-900 dark:text-zinc-100",
109+
"shadow-sm focus:ring focus:ring-primary/30 focus:ring-opacity-50",
110+
)}
111+
/>
112+
{hasWeightError && (
113+
<p className="text-xs mt-1 text-red-500 dark:text-red-400">
114+
Warning: This validator's weight is 20% or more of the current L1 total stake ({ Number(validator.validatorWeight * 10000n / l1TotalInitializedWeight / 100n).toFixed(2) }%). Recommended to be less than 20%.
115+
</p>
107116
)}
108-
/>
109-
{hasWeightError && (
110-
<p className="text-xs mt-1 text-red-500 dark:text-red-400">
111-
Warning: This validator's weight is 20% or more of the current L1 total stake ({ Number(validator.validatorWeight * 10000n / l1TotalInitializedWeight / 100n).toFixed(2) }%). Recommended to be less than 20%.
112-
</p>
113-
)}
114-
</div>
117+
</div>
118+
)}
115119
<div className="space-y-2">
116120
<label className="block text-sm font-medium text-zinc-700 dark:text-zinc-300">
117121
Validator Balance (P-Chain AVAX)

0 commit comments

Comments
 (0)