Skip to content

Commit

Permalink
Merge pull request #247 from lidofinance/develop
Browse files Browse the repository at this point in the history
Develop -> Main
  • Loading branch information
katamarinaki authored Feb 21, 2024
2 parents 19c7473 + 895f1da commit a1d05f1
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 11 deletions.
1 change: 1 addition & 0 deletions modules/blockChain/contractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const RewardsShareProgramRegistry: ChainAddressMap = {
}

export const SDVTRegistry: ChainAddressMap = {
[CHAINS.Mainnet]: '0xaE7B191A31f627b4eB1d4DaC64eaB9976995b433',
[CHAINS.Goerli]: '0x6370FA71b9Fd83aFC4196ee189a0d348C90E93b0',
[CHAINS.Holesky]: '0x11a93807078f8BB880c1BD0ee4C387537de4b4b6',
}
Expand Down
16 changes: 16 additions & 0 deletions modules/motions/evmAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ export const EvmAddressesByChain: EvmAddresses = {
[MotionType.PmlStablesTopUp]: '0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D',
[MotionType.AtcStablesTopUp]: '0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab',
[MotionType.LegoStablesTopUp]: '0x6AB39a8Be67D9305799c3F8FdFc95Caf3150d17c',
[MotionType.SDVTNodeOperatorsAdd]:
'0xcAa3AF7460E83E665EEFeC73a7a542E5005C9639',
[MotionType.SDVTNodeOperatorsActivate]:
'0xCBb418F6f9BFd3525CE6aADe8F74ECFEfe2DB5C8',
[MotionType.SDVTNodeOperatorsDeactivate]:
'0x8B82C1546D47330335a48406cc3a50Da732672E7',
[MotionType.SDVTVettedValidatorsLimitsSet]:
'0xD75778b855886Fc5e1eA7D6bFADA9EB68b35C19D',
[MotionType.SDVTTargetValidatorLimitsUpdate]:
'0x41CF3DbDc939c5115823Fba1432c4EC5E7bD226C',
[MotionType.SDVTNodeOperatorRewardAddressesSet]:
'0x589e298964b9181D9938B84bB034C3BB9024E2C0',
[MotionType.SDVTNodeOperatorNamesSet]:
'0x7d509BFF310d9460b1F613e4e40d342201a83Ae4',
[MotionType.SDVTNodeOperatorManagerChange]:
'0xE31A0599A6772BCf9b2bFc9e25cf941e793c9a7D',

// next motion factories are @deprecated
// we are keeping them here to display history data
Expand Down
1 change: 1 addition & 0 deletions modules/motions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export type Motion = {
enacted_at?: number
canceled_at?: number
rejected_at?: number
isOnChain: boolean
}

export type RawMotionOnchain = PromiseValue<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useSDVTNodeOperatorsList } from 'modules/motions/hooks/useSDVTNodeOpera
// SetNodeOperatorNames
export function DescSDVTNodeOperatorNamesSet({
callData,
isOnChain,
}: NestProps<SetNodeOperatorNamesAbi['decodeEVMScriptCallData']>) {
const { data: nodeOperatorsList } = useSDVTNodeOperatorsList()
return (
Expand All @@ -14,8 +15,9 @@ export function DescSDVTNodeOperatorNamesSet({
const nodeOperator = nodeOperatorsList?.[nodeOperatorId]
return (
<div key={nodeOperatorId}>
Change Node Operator <b>{nodeOperator ? nodeOperator.name : ''}</b>{' '}
(id: {nodeOperatorId}) name to <b>{item.name}</b>
Change Node Operator{' '}
<b>{nodeOperator && isOnChain ? nodeOperator.name : ''}</b> (id:{' '}
{nodeOperatorId}) name to <b>{item.name}</b>
{index === callData.length - 1 ? '.' : '; '}
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AddressInlineWithPop } from 'modules/shared/ui/Common/AddressInlineWith
// SetNodeOperatorRewardAddresses
export function DescSDVTNodeOperatorRewardAddressesSet({
callData,
isOnChain,
}: NestProps<SetNodeOperatorRewardAddressesAbi['decodeEVMScriptCallData']>) {
const { data: nodeOperatorsList } = useSDVTNodeOperatorsList()
return (
Expand All @@ -18,7 +19,7 @@ export function DescSDVTNodeOperatorRewardAddressesSet({
Change reward address of Node Operator{' '}
<b>{nodeOperator ? nodeOperator.name : ''}</b> (id: {nodeOperatorId}
)
{nodeOperator?.rewardAddress ? (
{nodeOperator?.rewardAddress && isOnChain ? (
<>
{' '}
from{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useSDVTNodeOperatorsList } from 'modules/motions/hooks/useSDVTNodeOpera
// UpdateTargetValidatorLimits
export function DescSDVTTargetValidatorLimitsUpdate({
callData,
isOnChain,
}: NestProps<UpdateTargetValidatorLimitsAbi['decodeEVMScriptCallData']>) {
const { data: nodeOperatorsList } = useSDVTNodeOperatorsList({
withSummary: true,
Expand All @@ -22,6 +23,7 @@ export function DescSDVTTargetValidatorLimitsUpdate({
<div key={nodeOperatorId}>
Disable target validator limit for Node Operator{' '}
<b>{nodeOperatorName}</b> (id: {nodeOperatorId})
{index === callData.length - 1 ? '.' : '; '}
</div>
)
}
Expand All @@ -30,7 +32,10 @@ export function DescSDVTTargetValidatorLimitsUpdate({
<div key={nodeOperatorId}>
Set target validator limit for Node Operator{' '}
<b>{nodeOperatorName}</b> (id: {nodeOperatorId}){' '}
{`from ${nodeOperator?.targetValidatorsCount} to ${item.targetLimit}`}
{nodeOperator && isOnChain
? `from ${nodeOperator.targetValidatorsCount} `
: ''}
{`to ${item.targetLimit}`}
{index === callData.length - 1 ? '.' : '; '}
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useSDVTNodeOperatorsList } from 'modules/motions/hooks/useSDVTNodeOpera
// SetVettedValidatorsLimits
export function DescSDVTVettedValidatorsLimitsSet({
callData,
isOnChain,
}: NestProps<SetVettedValidatorsLimitsAbi['decodeEVMScriptCallData']>) {
const { data: nodeOperatorsList } = useSDVTNodeOperatorsList({
withSummary: true,
Expand All @@ -18,7 +19,10 @@ export function DescSDVTVettedValidatorsLimitsSet({
<div key={nodeOperatorId}>
Set Node Operator <b>{nodeOperator ? nodeOperator.name : ''}</b>{' '}
(id: {nodeOperatorId}) vetted validators limit{' '}
{`from ${nodeOperator?.totalVettedValidators} to ${item.stakingLimit}`}
{nodeOperator && isOnChain
? `from ${nodeOperator.totalVettedValidators} `
: ''}
{`to ${item.stakingLimit}`}
</div>
)
})}
Expand Down
3 changes: 2 additions & 1 deletion modules/motions/ui/MotionDescription/MotionDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type DescNodeOperatorIncreaseLimitProps = NestProps<
>

type GenericDescProps = {
isOnChain?: boolean
callData: any
}

Expand Down Expand Up @@ -325,7 +326,7 @@ export function MotionDescription({ motion }: Props) {

return (
<DescWrap>
<Desc callData={callData} />
<Desc callData={callData} isOnChain={motion.isOnChain} />
</DescWrap>
)
}
1 change: 1 addition & 0 deletions modules/motions/ui/MotionDescription/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { UnpackedPromise } from 'modules/shared/utils/utilTypes'

export type NestProps<C extends (...a: any) => Promise<any>> = {
callData: UnpackedPromise<ReturnType<C>>
isOnChain?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const formParts = ({
const { watch, setValue, trigger } = useFormContext()
const selectedPrograms: Program[] = watch(fieldNames.programs)
const selectedTokenAddress: string = watch(fieldNames.tokenAddress)
const selectedTokenDecimals: number = watch(fieldNames.tokenDecimals)

const selectedTokenLabel = useMemo(() => {
if (!selectedTokenAddress || !allowedTokens?.length) {
Expand Down Expand Up @@ -295,7 +296,10 @@ export const formParts = ({
rules={{
required: 'Field is required',
validate: value => {
const tokenError = validateToken(value)
const tokenError = validateToken(
value,
selectedTokenDecimals,
)
if (tokenError) {
return tokenError
}
Expand Down
1 change: 1 addition & 0 deletions modules/motions/utils/formatMotionDataOnchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function formatMotionDataOnchain(rawMotion: RawMotionOnchain): Motion {
objectionsThreshold: Number(rawMotion.objectionsThreshold),
objectionsAmount: rawMotion.objectionsAmount,
evmScriptHash: rawMotion.evmScriptHash,
isOnChain: true,
}

return {
Expand Down
1 change: 1 addition & 0 deletions modules/motions/utils/formatMotionDataSubgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export function formatMotionDataSubgraph(rawMotion: RawMotionSubgraph): Motion {
rejected_at: rawMotion.rejected_at
? Number(rawMotion.rejected_at)
: undefined,
isOnChain: false,
}
}
9 changes: 5 additions & 4 deletions modules/tokens/utils/validateToken.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { utils } from 'ethers'
import { DEFAULT_DECIMALS } from 'modules/blockChain/constants'

export const validateToken = (value: string) => {
export const validateToken = (value: string, decimals = DEFAULT_DECIMALS) => {
if (Number(value) <= 0) {
return 'Must be positive'
return 'Value must be positive'
}
try {
utils.parseEther(value)
utils.parseUnits(value, decimals)
return null
} catch (_) {
return 'Unable to parse'
return 'Unable to parse value'
}
}

0 comments on commit a1d05f1

Please sign in to comment.