Skip to content

Commit 700a7ee

Browse files
authored
Merge pull request #13 from lidofinance/feature/si-1847-settings-page
Main settings and permissions forms
2 parents cef3f94 + ae08de3 commit 700a7ee

File tree

114 files changed

+3081
-372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3081
-372
lines changed

assets/icons/restore.svg

Lines changed: 3 additions & 0 deletions
Loading

consts/matomo-click-events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export const MATOMO_CLICK_EVENTS: Record<
1919
],
2020
[MATOMO_CLICK_EVENTS_TYPES.clickShowMoreWallets]: [
2121
'Staking_Vault_Widget',
22-
'Push "More wallets" on wallet submit-modal',
22+
'Push "More wallets" on wallet submit-permissions-modal',
2323
'staking_vault_widget_more_wallets',
2424
],
2525
[MATOMO_CLICK_EVENTS_TYPES.clickShowLessWallets]: [
2626
'Staking_Vault_Widget',
27-
'Push "Less wallets" on wallet submit-modal',
27+
'Push "Less wallets" on wallet submit-permissions-modal',
2828
'staking_vault_widget_less_wallets',
2929
],
3030
};

consts/roles.ts

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
import { keccak256, toHex } from 'viem/utils';
2+
import { Hex } from 'viem';
3+
4+
/**
5+
* @notice Permission for funding the StakingVault.
6+
*/
7+
export const FUND_ROLE = keccak256(toHex('vaults.Permissions.Fund'));
8+
9+
/**
10+
* @notice Permission for withdrawing funds from the StakingVault.
11+
*/
12+
export const WITHDRAW_ROLE = keccak256(toHex('vaults.Permissions.Withdraw'));
13+
14+
/**
15+
* @notice Permission for locking ether on StakingVault.
16+
*/
17+
export const LOCK_ROLE = keccak256(toHex('vaults.Permissions.Lock'));
18+
19+
/**
20+
* @notice Permission for minting stETH shares backed by the StakingVault.
21+
*/
22+
export const MINT_ROLE = keccak256(toHex('vaults.Permissions.Mint'));
23+
24+
/**
25+
* @notice Permission for burning stETH shares backed by the StakingVault.
26+
*/
27+
export const BURN_ROLE = keccak256(toHex('vaults.Permissions.Burn'));
28+
29+
/**
30+
* @notice Permission for rebalancing the StakingVault.
31+
*/
32+
export const REBALANCE_ROLE = keccak256(toHex('vaults.Permissions.Rebalance'));
33+
34+
/**
35+
* @notice Permission for pausing beacon chain deposits on the StakingVault.
36+
*/
37+
export const PAUSE_BEACON_CHAIN_DEPOSITS_ROLE = keccak256(
38+
toHex('vaults.Permissions.PauseDeposits'),
39+
);
40+
41+
/**
42+
* @notice Permission for resuming beacon chain deposits on the StakingVault.
43+
*/
44+
export const RESUME_BEACON_CHAIN_DEPOSITS_ROLE = keccak256(
45+
toHex('vaults.Permissions.ResumeDeposits'),
46+
);
47+
48+
/**
49+
* @notice Permission for requesting validator exit from the StakingVault.
50+
*/
51+
export const REQUEST_VALIDATOR_EXIT_ROLE = keccak256(
52+
toHex('vaults.Permissions.RequestValidatorExit'),
53+
);
54+
55+
/**
56+
* @notice Permission for triggering validator withdrawal from the StakingVault using EIP-7002 triggerable exit.
57+
*/
58+
export const TRIGGER_VALIDATOR_WITHDRAWAL_ROLE = keccak256(
59+
toHex('vaults.Permissions.TriggerValidatorWithdrawal'),
60+
);
61+
62+
/**
63+
* @notice Permission for voluntary disconnecting the StakingVault.
64+
*/
65+
export const VOLUNTARY_DISCONNECT_ROLE = keccak256(
66+
toHex('vaults.Permissions.VoluntaryDisconnect'),
67+
);
68+
69+
/**
70+
* @notice Node operator manager role:
71+
* - confirms confirm expiry;
72+
* - confirms ownership transfer;
73+
* - assigns NODE_OPERATOR_FEE_CONFIRM_ROLE;
74+
* - assigns NODE_OPERATOR_FEE_CLAIM_ROLE.
75+
*/
76+
export const NODE_OPERATOR_MANAGER_ROLE = keccak256(
77+
toHex('vaults.Delegation.NodeOperatorManagerRole'),
78+
);
79+
80+
/**
81+
* @notice Claims node operator fee.
82+
*/
83+
export const NODE_OPERATOR_FEE_CLAIM_ROLE = keccak256(
84+
toHex('vaults.Delegation.NodeOperatorFeeClaimRole'),
85+
);
86+
87+
export const RECOVER_ASSETS_ROLE = keccak256(
88+
toHex('vaults.Dashboard.RecoverAssets'),
89+
);
90+
91+
/**
92+
* @notice Adjusts rewards to allow fee correction during side deposits or consolidations
93+
*/
94+
export const NODE_OPERATOR_REWARDS_ADJUST_ROLE = keccak256(
95+
toHex('vaults.NodeOperatorFee.RewardsAdjustRole'),
96+
);
97+
98+
/**
99+
* @notice Permission for getting compensation for disproven validator predeposit from PDG
100+
*/
101+
export const PDG_COMPENSATE_PREDEPOSIT_ROLE = keccak256(
102+
toHex('vaults.Permissions.PDGCompensatePredeposit'),
103+
);
104+
105+
/**
106+
* @notice Permission for proving valid vault validators unknown to the PDG
107+
*/
108+
export const PDG_PROVE_VALIDATOR_ROLE = keccak256(
109+
toHex('vaults.Permissions.PDGProveValidator'),
110+
);
111+
112+
/**
113+
* @notice Permission for unguarnateed deposit to trusted validators
114+
*/
115+
export const UNGUARANTEED_BEACON_CHAIN_DEPOSIT_ROLE = keccak256(
116+
toHex('vaults.Permissions.UnguaranteedBeaconChainDeposit'),
117+
);
118+
119+
/**
120+
* @dev Permission for deauthorizing Lido VaultHub from the StakingVault.
121+
*/
122+
export const LIDO_VAULTHUB_DEAUTHORIZATION_ROLE = keccak256(
123+
toHex('vaults.Permissions.LidoVaultHubDeauthorization'),
124+
);
125+
126+
/**
127+
* @dev Permission for granting authorization to Lido VaultHub on the StakingVault.
128+
*/
129+
export const LIDO_VAULTHUB_AUTHORIZATION_ROLE = keccak256(
130+
toHex('vaults.Permissions.LidoVaultHubAuthorization'),
131+
);
132+
133+
/**
134+
* @dev Permission for ossifying the StakingVault.
135+
*/
136+
export const OSSIFY_ROLE = keccak256(toHex('vaults.Permissions.Ossify'));
137+
138+
/**
139+
* @dev Permission for setting depositor on the StakingVault.
140+
*/
141+
export const SET_DEPOSITOR_ROLE = keccak256(
142+
toHex('vaults.Permissions.SetDepositor'),
143+
);
144+
145+
/**
146+
* @dev Permission for resetting locked amount on the disconnected StakingVault.
147+
*/
148+
export const RESET_LOCKED_ROLE = keccak256(
149+
toHex('vaults.Permissions.ResetLocked'),
150+
);
151+
152+
/**
153+
* @dev Permission for requesting change of tier on the OperatorGrid.
154+
*/
155+
export const REQUEST_TIER_CHANGE_ROLE = keccak256(
156+
toHex('vaults.Permissions.RequestTierChange'),
157+
);
158+
159+
/**
160+
* @notice default vault admin role.
161+
*/
162+
export const DEFAULT_ADMIN_ROLE =
163+
'0x0000000000000000000000000000000000000000000000000000000000000000' as Hex;
164+
165+
export const permissions = {
166+
FUND_ROLE,
167+
WITHDRAW_ROLE,
168+
LOCK_ROLE,
169+
MINT_ROLE,
170+
BURN_ROLE,
171+
REBALANCE_ROLE,
172+
PAUSE_BEACON_CHAIN_DEPOSITS_ROLE,
173+
RESUME_BEACON_CHAIN_DEPOSITS_ROLE,
174+
REQUEST_VALIDATOR_EXIT_ROLE,
175+
TRIGGER_VALIDATOR_WITHDRAWAL_ROLE,
176+
VOLUNTARY_DISCONNECT_ROLE,
177+
RECOVER_ASSETS_ROLE,
178+
NODE_OPERATOR_FEE_CLAIM_ROLE,
179+
NODE_OPERATOR_REWARDS_ADJUST_ROLE,
180+
PDG_COMPENSATE_PREDEPOSIT_ROLE,
181+
PDG_PROVE_VALIDATOR_ROLE,
182+
UNGUARANTEED_BEACON_CHAIN_DEPOSIT_ROLE,
183+
LIDO_VAULTHUB_DEAUTHORIZATION_ROLE,
184+
LIDO_VAULTHUB_AUTHORIZATION_ROLE,
185+
OSSIFY_ROLE,
186+
SET_DEPOSITOR_ROLE,
187+
RESET_LOCKED_ROLE,
188+
REQUEST_TIER_CHANGE_ROLE,
189+
};
190+
191+
export const permissionsKeys = Object.keys(permissions) as PERMISSION[];
192+
export type EntirePermissionsType = typeof permissions;
193+
export type PERMISSION = keyof EntirePermissionsType;

features/create-vault/create-vault-form/create-vault-form-context/create-vault-form-context.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,15 @@ import {
2525
CreateVaultStep,
2626
SubmittingInfo,
2727
} from 'features/create-vault/types';
28-
import {
29-
createVaultFormValidator,
30-
createVaultSchema,
31-
CreateVaultSchema,
32-
formatCreateVaultData,
33-
} from './validation';
34-
28+
import { createVaultSchema, CreateVaultSchema } from './validation';
29+
import { validateFormWithZod } from 'utils/validate-form-value';
3530
import {
3631
ToggleValue,
3732
PermissionToggleEnum,
3833
CREATE_VAULT_FORM_STEPS,
3934
} from 'features/create-vault/consts';
4035
import { SubmitStepEnum } from 'features/create-vault/types';
36+
import { formatCreateVaultData } from 'features/create-vault/utils/format-data';
4137
import { simulateCreateVault } from 'modules/vaults/contracts/vault-factory';
4238

4339
const CreateVaultDataContext =
@@ -48,7 +44,7 @@ export const useCreateVaultFormData = () => {
4844
const value = useContext(CreateVaultDataContext);
4945
invariant(
5046
value,
51-
'useCreateVaultData was used outside the CreateVaultDataContext provider',
47+
'useCreateVaultFormData was used outside the CreateVaultDataContext provider',
5248
);
5349

5450
return value;
@@ -96,7 +92,7 @@ export const CreateFormProvider: FC<PropsWithChildren> = ({ children }) => {
9692
defaultAdmin: '',
9793
roles: {},
9894
},
99-
resolver: createVaultFormValidator(createVaultSchema),
95+
resolver: validateFormWithZod(createVaultSchema),
10096
mode: 'all',
10197
});
10298

0 commit comments

Comments
 (0)