Skip to content

Commit

Permalink
Merge branch 'develop' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Dec 12, 2024
2 parents 0d26e6e + 3090a3b commit 692827b
Show file tree
Hide file tree
Showing 145 changed files with 5,971 additions and 1,293 deletions.
9 changes: 5 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
# Changes to the genesis builder should be approved by Konstantinos or Mirko at least
/crates/iota-genesis-builder/ @kodemartin @miker83z

# vm-language team
/iota-execution/ @iotaledger/vm-language
/external-crates/ @iotaledger/vm-language

# infrastructure team
/docker/ @iotaledger/infrastructure @iotaledger/node @iotaledger/devops-admin
/crates/iota-json-rpc*/ @iotaledger/infrastructure
Expand Down Expand Up @@ -61,6 +57,11 @@ prettier.config.js @iotaledger/tooling
turbo.json @iotaledger/tooling
vercel.json @iotaledger/tooling

# vm-language team
# Needs to be after package.json ownership definition to override it
/iota-execution/ @iotaledger/vm-language
/external-crates/ @iotaledger/vm-language

# Docs and examples are for DevEx to approve upon
/docs/ @iotaledger/devx
/examples/ @iotaledger/devx
Expand Down
27 changes: 8 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
matrix:
os: [
self-hosted, # ubuntu-x86_64
# TODO: uncomment when runners are public available https://github.com/iotaledger/iota/issues/4421
# ubuntu-arm64, # ubuntu-arm64
macos-latest, # macos-arm64
# windows-latest (windows-x86_64) is disabled because we need to add custom logic for authenticating
# git for private repositories during the build (needed for iota-msim)
# MrSquaare/ssh-setup-action@v3 does not support windows
windows-latest, # windows-x86_64
]
fail-fast: false
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -108,10 +108,10 @@ jobs:
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
choco install postgresql12 --force --params '/Password:root'
echo "C:\Program Files\PostgreSQL\12\bin" >> $GITHUB_PATH
echo "C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_PATH
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_ENV
choco install postgresql16 --force --params '/Password:root'
echo "C:\Program Files\PostgreSQL\16\bin" >> $GITHUB_PATH
echo "C:\Program Files\PostgreSQL\16\lib" >> $GITHUB_PATH
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\16\lib" >> $GITHUB_ENV
echo "PG_DATABASE_URL=postgres://postgres:root@localhost/" >> $GITHUB_ENV
echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres:root@localhost/diesel_example" >> $GITHUB_ENV
Expand All @@ -126,6 +126,7 @@ jobs:
run: |
brew install postgresql
# TODO: uncomment when runners are public available https://github.com/iotaledger/iota/issues/4421
# NOTE: Self-hosted runners should already have postgres installed
# - name: Install postgres (Ubuntu arm64)
# if: ${{ matrix.os == 'ubuntu-arm64' }}
Expand Down Expand Up @@ -227,15 +228,3 @@ jobs:
# env:
# # https://github.com/settings/tokens/new?scopes=public_repo,workflow
# COMMITTER_TOKEN: ${{ secrets.HOMEBREW_GH_FORMULA_BUMP }}
#
# # Tag all iota images with release tag, so that they can be easily found
# tag-docker-hub-images:
# runs-on: ubuntu-latest
# steps:
# - name: Dispatch Tagging of images in DockerHub, in MystenLabs/sui-operations
# uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
# with:
# repository: iotaledger/iota
# token: ${{ secrets.DOCKER_BINARY_BUILDS_DISPATCH }}
# event-type: tag-docker-images
# client-payload: '{"iota_commit": "${{ github.sha }}", "repo_name": "all", "tag": "${{ env.TAG_NAME }}"}'
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/apps-backend/src/features/features.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class FeaturesController {
defaultValue: false,
},
[Feature.StardustMigration]: {
defaultValue: false,
defaultValue: true,
},
[Feature.SupplyIncreaseVesting]: {
defaultValue: true,
Expand Down
78 changes: 9 additions & 69 deletions apps/core/src/components/stake/StakedCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,10 @@ import { Card, CardImage, CardType, CardBody, CardAction, CardActionType } from
import { useMemo } from 'react';
import { useIotaClientQuery } from '@iota/dapp-kit';
import { ImageIcon } from '../icon';
import { determineCountDownText, ExtendedDelegatedStake } from '../../utils';
import { TimeUnit, useFormatCoin, useGetTimeBeforeEpochNumber, useTimeAgo } from '../../hooks';
import { NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE } from '../../constants';
import { ExtendedDelegatedStake } from '../../utils';
import { useFormatCoin, useStakeRewardStatus } from '../../hooks';
import React from 'react';

export enum StakeState {
WarmUp = 'WARM_UP',
Earning = 'EARNING',
CoolDown = 'COOL_DOWN',
Withdraw = 'WITHDRAW',
InActive = 'IN_ACTIVE',
}

const STATUS_COPY: { [key in StakeState]: string } = {
[StakeState.WarmUp]: 'Starts Earning',
[StakeState.Earning]: 'Staking Rewards',
[StakeState.CoolDown]: 'Available to withdraw',
[StakeState.Withdraw]: 'Withdraw',
[StakeState.InActive]: 'Inactive',
};

interface StakedCardProps {
extendedStake: ExtendedDelegatedStake;
currentEpoch: number;
Expand All @@ -45,48 +28,20 @@ export function StakedCard({
}: StakedCardProps) {
const { principal, stakeRequestEpoch, estimatedReward, validatorAddress } = extendedStake;

// TODO: Once two step withdraw is available, add cool down and withdraw now logic
// For cool down epoch, show Available to withdraw add rewards to principal
// Reward earning epoch is 2 epochs after stake request epoch
const earningRewardsEpoch =
Number(stakeRequestEpoch) + NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE;
const isEarnedRewards = currentEpoch >= Number(earningRewardsEpoch);
const delegationState = inactiveValidator
? StakeState.InActive
: isEarnedRewards
? StakeState.Earning
: StakeState.WarmUp;

const rewards = isEarnedRewards && estimatedReward ? BigInt(estimatedReward) : 0n;
const { rewards, title, subtitle } = useStakeRewardStatus({
stakeRequestEpoch,
currentEpoch,
estimatedReward,
inactiveValidator,
});

// For inactive validator, show principal + rewards
const [principalStaked, symbol] = useFormatCoin(
inactiveValidator ? principal + rewards : principal,
IOTA_TYPE_ARG,
);
const [rewardsStaked] = useFormatCoin(rewards, IOTA_TYPE_ARG);

// Applicable only for warm up
const epochBeforeRewards = delegationState === StakeState.WarmUp ? earningRewardsEpoch : null;

const statusText = {
// Epoch time before earning
[StakeState.WarmUp]: `Epoch #${earningRewardsEpoch}`,
[StakeState.Earning]: `${rewardsStaked} ${symbol}`,
// Epoch time before redrawing
[StakeState.CoolDown]: `Epoch #`,
[StakeState.Withdraw]: 'Now',
[StakeState.InActive]: 'Not earning rewards',
};

const { data } = useIotaClientQuery('getLatestIotaSystemState');
const { data: rewardEpochTime } = useGetTimeBeforeEpochNumber(Number(epochBeforeRewards) || 0);
const timeAgo = useTimeAgo({
timeFrom: rewardEpochTime || null,
shortedTimeLabel: false,
shouldEnd: true,
maxTimeUnit: TimeUnit.ONE_HOUR,
});

const validatorMeta = useMemo(() => {
if (!data) return null;
Expand All @@ -97,17 +52,6 @@ export function StakedCard({
);
}, [validatorAddress, data]);

const rewardTime = () => {
if (Number(epochBeforeRewards) && rewardEpochTime > 0) {
return determineCountDownText({
timeAgo,
label: 'in',
});
}

return statusText[delegationState];
};

return (
<Card testId="staked-card" type={CardType.Default} isHoverable onClick={onClick}>
<CardImage>
Expand All @@ -118,11 +62,7 @@ export function StakedCard({
/>
</CardImage>
<CardBody title={validatorMeta?.name || ''} subtitle={`${principalStaked} ${symbol}`} />
<CardAction
title={rewardTime()}
subtitle={STATUS_COPY[delegationState]}
type={CardActionType.SupportingText}
/>
<CardAction title={title} subtitle={subtitle} type={CardActionType.SupportingText} />
</Card>
);
}
1 change: 1 addition & 0 deletions apps/core/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ export * from './useNFTBasicData';
export * from './useOwnedNFT';
export * from './useNftDetails';
export * from './useCountdownByTimestamp';
export * from './useStakeRewardStatus';

export * from './stake';
92 changes: 92 additions & 0 deletions apps/core/src/hooks/useStakeRewardStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils';
import { NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE } from '../constants';
import { useFormatCoin, useGetTimeBeforeEpochNumber, useTimeAgo, TimeUnit } from '.';
import { determineCountDownText } from '../utils';

export function useStakeRewardStatus({
stakeRequestEpoch,
currentEpoch,
inactiveValidator,
estimatedReward,
}: {
stakeRequestEpoch: string;
currentEpoch: number;
inactiveValidator: boolean;
estimatedReward?: string | number | bigint;
}) {
// TODO: Once two step withdraw is available, add cool down and withdraw now logic
// For cool down epoch, show Available to withdraw add rewards to principal
// Reward earning epoch is 2 epochs after stake request epoch
const earningRewardsEpoch =
Number(stakeRequestEpoch) + NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE;

const isEarnedRewards = currentEpoch >= Number(earningRewardsEpoch);

const delegationState = inactiveValidator
? StakeState.InActive
: isEarnedRewards
? StakeState.Earning
: StakeState.WarmUp;

const rewards = isEarnedRewards && estimatedReward ? BigInt(estimatedReward) : 0n;

const [rewardsStaked, symbol] = useFormatCoin(rewards, IOTA_TYPE_ARG);

// Applicable only for warm up
const epochBeforeRewards = delegationState === StakeState.WarmUp ? earningRewardsEpoch : null;

const statusText = {
// Epoch time before earning
[StakeState.WarmUp]: `Epoch #${earningRewardsEpoch}`,
[StakeState.Earning]: `${rewardsStaked} ${symbol}`,
// Epoch time before redrawing
[StakeState.CoolDown]: `Epoch #`,
[StakeState.Withdraw]: 'Now',
[StakeState.InActive]: 'Not earning rewards',
};

const { data: rewardEpochTime } = useGetTimeBeforeEpochNumber(Number(epochBeforeRewards) || 0);

const timeAgo = useTimeAgo({
timeFrom: rewardEpochTime || null,
shortedTimeLabel: false,
shouldEnd: true,
maxTimeUnit: TimeUnit.ONE_HOUR,
});

const rewardTime = () => {
if (Number(epochBeforeRewards) && rewardEpochTime > 0) {
return determineCountDownText({
timeAgo,
label: 'in',
});
}

return statusText[delegationState];
};

return {
rewards,
title: rewardTime(),
subtitle: STATUS_COPY[delegationState],
};
}
export enum StakeState {
WarmUp = 'WARM_UP',
Earning = 'EARNING',
CoolDown = 'COOL_DOWN',
Withdraw = 'WITHDRAW',
InActive = 'IN_ACTIVE',
}
export const STATUS_COPY: {
[key in StakeState]: string;
} = {
[StakeState.WarmUp]: 'Starts Earning',
[StakeState.Earning]: 'Staking Rewards',
[StakeState.CoolDown]: 'Available to withdraw',
[StakeState.Withdraw]: 'Withdraw',
[StakeState.InActive]: 'Inactive',
};
2 changes: 1 addition & 1 deletion apps/explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@vitejs/plugin-react": "^4.3.1",
"@vitest/ui": "^0.33.0",
"autoprefixer": "^10.4.19",
"happy-dom": "^10.5.1",
"happy-dom": "^15.11.7",
"onchange": "^7.1.0",
"postcss": "^8.4.31",
"start-server-and-test": "^2.0.0",
Expand Down
27 changes: 9 additions & 18 deletions apps/wallet-dashboard/app/(protected)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,35 @@
// SPDX-License-Identifier: Apache-2.0
'use client';

import { AccountBalance, MyCoins, TransactionsOverview, StakingOverview } from '@/components';
import {
AccountBalance,
MyCoins,
TransactionsOverview,
StakingOverview,
MigrationOverview,
} from '@/components';
import { useFeature } from '@growthbook/growthbook-react';
import { Feature } from '@iota/core';
import { useCurrentAccount, useCurrentWallet } from '@iota/dapp-kit';
import clsx from 'clsx';

function HomeDashboardPage(): JSX.Element {
const { connectionStatus } = useCurrentWallet();
const account = useCurrentAccount();

const stardustMigrationEnabled = useFeature<boolean>(Feature.StardustMigration).value;
// Add the logic here to check if the user has migration objects.
const needsMigration = false && stardustMigrationEnabled;

return (
<main className="flex flex-1 flex-col items-center space-y-8 py-md">
{connectionStatus === 'connected' && account && (
<>
<div
className={clsx(
'home-page-grid-container h-full w-full',
needsMigration && 'with-migration',
)}
>
<div className="home-page-grid-container h-full w-full">
<div style={{ gridArea: 'balance' }} className="flex grow overflow-hidden">
<AccountBalance />
</div>
<div style={{ gridArea: 'staking' }} className="flex grow overflow-hidden">
<StakingOverview />
</div>
{needsMigration && (
<div
style={{ gridArea: 'migration' }}
className="flex grow overflow-hidden"
>
Migration
</div>
)}
{stardustMigrationEnabled && <MigrationOverview />}
<div style={{ gridArea: 'coins' }}>
<MyCoins />
</div>
Expand Down
11 changes: 7 additions & 4 deletions apps/wallet-dashboard/app/(protected)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ function DashboardLayout({ children }: PropsWithChildren): JSX.Element {
<Sidebar />
</div>

<div className="container relative flex min-h-screen flex-col">
<div className="sticky top-0 z-10 backdrop-blur-lg">
<TopNav />
{/* This padding need to have aligned left/right content's position, because of sidebar overlap on the small screens */}
<div className="pl-[72px]">
<div className="container relative flex min-h-screen flex-col">
<div className="sticky top-0 z-10 backdrop-blur-lg">
<TopNav />
</div>
<div className="flex-1 py-md--rs">{children}</div>
</div>
<div className="flex-1 py-md--rs">{children}</div>
</div>

<div className="fixed bottom-5 right-5">
Expand Down
Loading

0 comments on commit 692827b

Please sign in to comment.